Skip to content

Commit 092910d

Browse files
committed
Revert "Update kernel.py"
This reverts commit d375021.
1 parent d375021 commit 092910d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

jupyter-cpp-kernel/kernel.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,17 @@ 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"
95104

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"
105+
main_foot = "\nreturn 0;\n}"
100106

101107
def __init__(self, *args, **kwargs):
102108
super(CPPKernel, self).__init__(*args, **kwargs)
@@ -142,7 +148,8 @@ def _write_to_stdout(self, contents):
142148
'text/markdown': contents
143149
},
144150
'metadata': {}
145-
})
151+
}
152+
)
146153

147154
def _write_to_stderr(self, contents):
148155
self.send_response(self.iopub_socket, 'stream', {'name': 'stderr', 'text': contents})
@@ -240,14 +247,15 @@ def _support_external_header(self, code):
240247
def _add_main(self, magics, code):
241248

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

245252
# User input
246253
code = re.sub(r'(std::)?cin *>>', r'std::cout<<GET_INPUT_STREAM_JP;std::cin >>', code)
247254
code = re.sub(r'(std::)?getline *', r'std::cout<<GET_INPUT_STREAM_JP;std::getline ', code)
248255

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

252260
# Support External C/C++ header
253261
code = self._support_external_header(code)

0 commit comments

Comments
 (0)