Skip to content

Commit d375021

Browse files
committed
Update kernel.py
1 parent 0efd2df commit d375021

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

jupyter-cpp-kernel/kernel.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,11 @@ class CPPKernel(Kernel):
9292
'mimetype': 'text/markdown',
9393
'file_extension': '.cpp'
9494
}
95-
96-
introduction = "C++ 14 kernel for Jupyter (main), version 1.0.0a5\n\n"
97-
cp_banner = "Copyright (C) 2023 shiroinekotfs\nCopyright (C) Brendan Rius\nCopyright (C) Free Software Foundation, Inc\n\n"
98-
links_guide = "Legal information: https://github.com/shiroinekotfs/jupyter-cpp-kernel/blob/master/LICENSE\nNotebook tutorial: https://github.com/shiroinekotfs/jupyter-cpp-kernel-doc\n\nAuthor GitHub profile: https://github.com/shiroinekotfs\n"
99-
reporting_links = "Reporting the issue: https://github.com/shiroinekotfs/jupyter-cpp-kernel/issues"
100-
101-
banner = introduction + cp_banner + links_guide + reporting_links
102-
103-
main_head = "#include <iostream>\n" + "int main(){\n"
10495

105-
main_foot = "\nreturn 0;\n}"
96+
banner = "C++ 14 kernel for Jupyter (main), version 1.0.0a5\n\n"
97+
+ "Copyright (C) 2023 shiroinekotfs\nCopyright (C) Brendan Rius\nCopyright (C) Free Software Foundation, Inc\n\n"
98+
+ "Legal information: https://github.com/shiroinekotfs/jupyter-cpp-kernel/blob/master/LICENSE\nNotebook tutorial: https://github.com/shiroinekotfs/jupyter-cpp-kernel-doc\n\nAuthor GitHub profile: https://github.com/shiroinekotfs\n"
99+
+ "Reporting the issue: https://github.com/shiroinekotfs/jupyter-cpp-kernel/issues"
106100

107101
def __init__(self, *args, **kwargs):
108102
super(CPPKernel, self).__init__(*args, **kwargs)
@@ -148,8 +142,7 @@ def _write_to_stdout(self, contents):
148142
'text/markdown': contents
149143
},
150144
'metadata': {}
151-
}
152-
)
145+
})
153146

154147
def _write_to_stderr(self, contents):
155148
self.send_response(self.iopub_socket, 'stream', {'name': 'stderr', 'text': contents})
@@ -247,15 +240,14 @@ def _support_external_header(self, code):
247240
def _add_main(self, magics, code):
248241

249242
if "int main(" not in code:
250-
code = self.main_head + "\n" + code + "\n" + self.main_foot
243+
code = "#include <iostream>\n" + "int main(){\n\n" + code + "\n\nreturn 0;\n}"
251244

252245
# User input
253246
code = re.sub(r'(std::)?cin *>>', r'std::cout<<GET_INPUT_STREAM_JP;std::cin >>', code)
254247
code = re.sub(r'(std::)?getline *', r'std::cout<<GET_INPUT_STREAM_JP;std::getline ', code)
255248

256249
# Include Global header
257-
global_header = "#include" + "\"" + self.resDir + "/gcpph.hpp" + "\""
258-
code = global_header + "\n" + code
250+
code = "#include" + "\"" + self.resDir + "/gcpph.hpp" + "\" \n" + code
259251

260252
# Support External C/C++ header
261253
code = self._support_external_header(code)

0 commit comments

Comments
 (0)