Skip to content

Commit 5398530

Browse files
committed
use xeus's routines in kernel_info_request_impl
1 parent d3b7b77 commit 5398530

File tree

2 files changed

+36
-42
lines changed

2 files changed

+36
-42
lines changed

src/xinterpreter.cpp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -270,19 +270,6 @@ namespace xpyt
270270

271271
nl::json interpreter::kernel_info_request_impl()
272272
{
273-
nl::json result;
274-
result["implementation"] = "xeus-python";
275-
result["implementation_version"] = XPYT_VERSION;
276-
277-
/* The jupyter-console banner for xeus-python is the following:
278-
__ _____ _ _ ___
279-
\ \/ / _ \ | | / __|
280-
> < __/ |_| \__ \
281-
/_/\_\___|\__,_|___/
282-
283-
xeus-python: a Jupyter lernel for Python
284-
*/
285-
286273
std::string banner = ""
287274
" __ _____ _ _ ___\n"
288275
" \\ \\/ / _ \\ | | / __|\n"
@@ -299,22 +286,28 @@ namespace xpyt
299286
"We recommend using a general-purpose package manager instead, such as Conda/Mamba."
300287
"\n");
301288
#endif
302-
result["banner"] = banner;
303-
result["debugger"] = (PY_MAJOR_VERSION != 3) || (PY_MAJOR_VERSION != 13);
304-
305-
result["language_info"]["name"] = "python";
306-
result["language_info"]["version"] = PY_VERSION;
307-
result["language_info"]["mimetype"] = "text/x-python";
308-
result["language_info"]["file_extension"] = ".py";
309289

310-
result["help_links"] = nl::json::array();
311-
result["help_links"][0] = nl::json::object({
290+
nl::json help_links = nl::json::array();
291+
help_links.push_back({
312292
{"text", "Xeus-Python Reference"},
313293
{"url", "https://xeus-python.readthedocs.io"}
314294
});
315295

316-
result["status"] = "ok";
317-
return result;
296+
return xeus::create_info_reply(
297+
"", // protocol_version
298+
"xeus-python", // implementation
299+
XPYT_VERSION, // implementation_version
300+
"python", // language_name
301+
PY_VERSION, // language_version
302+
"text/x-python", // language_mimetype
303+
".py", // language_file_extension
304+
"", // pygments_lexer
305+
"", // language_codemirror_mode
306+
"", // language_nbconvert_exporter
307+
banner, // banner
308+
(PY_MAJOR_VERSION != 3) || (PY_MAJOR_VERSION != 13), // debugger
309+
help_links // help_links
310+
);
318311
}
319312

320313
void interpreter::shutdown_request_impl()

src/xinterpreter_raw.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,6 @@ namespace xpyt
278278

279279
nl::json raw_interpreter::kernel_info_request_impl()
280280
{
281-
nl::json result;
282-
result["implementation"] = "xeus-python";
283-
result["implementation_version"] = XPYT_VERSION;
284281

285282
/* The jupyter-console banner for xeus-python is the following:
286283
__ _____ _ _ ___
@@ -307,24 +304,28 @@ namespace xpyt
307304
"We recommend using a general-purpose package manager instead, such as Conda/Mamba."
308305
"\n");
309306
#endif
310-
result["banner"] = banner;
311-
result["debugger"] = false;
312307

313-
result["language_info"]["name"] = "python";
314-
result["language_info"]["version"] = PY_VERSION;
315-
result["language_info"]["mimetype"] = "text/x-python";
316-
result["language_info"]["file_extension"] = ".py";
308+
nl::json help_links = nl::json::array();
309+
help_links.push_back({
310+
{"text", "Xeus-Python Reference"},
311+
{"url", "https://xeus-python.readthedocs.io"}
312+
});
317313

318-
result["help_links"] = nl::json::array();
319-
result["help_links"][0] = nl::json::object(
320-
{
321-
{"text", "Xeus-Python Reference"},
322-
{"url", "https://xeus-python.readthedocs.io"}
323-
}
314+
return xeus::create_info_reply(
315+
"", // protocol_version
316+
"xeus-python", // implementation
317+
XPYT_VERSION, // implementation_version
318+
"python", // language_name
319+
PY_VERSION, // language_version
320+
"text/x-python", // language_mimetype
321+
".py", // language_file_extension
322+
"", // pygments_lexer
323+
"", // language_codemirror_mode
324+
"", // language_nbconvert_exporter
325+
banner, // banner
326+
false, // debugger
327+
help_links // help_links
324328
);
325-
326-
result["status"] = "ok";
327-
return result;
328329
}
329330

330331
void raw_interpreter::shutdown_request_impl()

0 commit comments

Comments
 (0)