##// END OF EJS Templates
move language name, version into language_info...
Min RK -
Show More
@@ -240,9 +240,6 b' define(['
240 this.events.on('kernel_ready.Kernel', function(event, data) {
240 this.events.on('kernel_ready.Kernel', function(event, data) {
241 var kinfo = data.kernel.info_reply;
241 var kinfo = data.kernel.info_reply;
242 var langinfo = kinfo.language_info || {};
242 var langinfo = kinfo.language_info || {};
243 if (!langinfo.name) {
244 langinfo.name = kinfo.language;
245 }
246 that.metadata.language_info = langinfo;
243 that.metadata.language_info = langinfo;
247 // Mode 'null' should be plain, unhighlighted text.
244 // Mode 'null' should be plain, unhighlighted text.
248 var cm_mode = langinfo.codemirror_mode || langinfo.name || 'null';
245 var cm_mode = langinfo.codemirror_mode || langinfo.name || 'null';
@@ -102,16 +102,20 b' class V5toV4(Adapter):'
102 # shell channel
102 # shell channel
103
103
104 def kernel_info_reply(self, msg):
104 def kernel_info_reply(self, msg):
105 v4c = {}
105 content = msg['content']
106 content = msg['content']
106 content.pop('banner', None)
107 for key in ('language_version', 'protocol_version'):
107 for key in ('language_version', 'protocol_version'):
108 if key in content:
108 if key in content:
109 content[key] = _version_str_to_list(content[key])
109 v4c[key] = _version_str_to_list(content[key])
110 if content.pop('implementation', '') == 'ipython' \
110 if content.get('implementation', '') == 'ipython' \
111 and 'implementation_version' in content:
111 and 'implementation_version' in content:
112 content['ipython_version'] = content.pop('implmentation_version')
112 v4c['ipython_version'] = _version_str_to_list(content['implementation_version'])
113 content.pop('implementation_version', None)
113 language_info = content.get('language_info', {})
114 content.setdefault("implmentation", content['language'])
114 language = language_info.get('name', '')
115 v4c.setdefault('language', language)
116 if 'version' in language_info:
117 v4c.setdefault('language_version', _version_str_to_list(language_info['version']))
118 msg['content'] = v4c
115 return msg
119 return msg
116
120
117 def execute_request(self, msg):
121 def execute_request(self, msg):
@@ -204,14 +208,23 b' class V4toV5(Adapter):'
204
208
205 def kernel_info_reply(self, msg):
209 def kernel_info_reply(self, msg):
206 content = msg['content']
210 content = msg['content']
207 for key in ('language_version', 'protocol_version', 'ipython_version'):
211 for key in ('protocol_version', 'ipython_version'):
208 if key in content:
212 if key in content:
209 content[key] = ".".join(map(str, content[key]))
213 content[key] = '.'.join(map(str, content[key]))
214
215 content.setdefault('protocol_version', '4.1')
210
216
211 if content['language'].startswith('python') and 'ipython_version' in content:
217 if content['language'].startswith('python') and 'ipython_version' in content:
212 content['implementation'] = 'ipython'
218 content['implementation'] = 'ipython'
213 content['implementation_version'] = content.pop('ipython_version')
219 content['implementation_version'] = content.pop('ipython_version')
214
220
221 language = content.pop('language')
222 language_info = content.setdefault('language_info', {})
223 language_info.setdefault('name', language)
224 if 'language_version' in content:
225 language_version = '.'.join(map(str, content.pop('language_version')))
226 language_info.setdefault('version', language_version)
227
215 content['banner'] = ''
228 content['banner'] = ''
216 return msg
229 return msg
217
230
@@ -169,6 +169,26 b' class V4toV5TestCase(AdapterTest):'
169 text = v5c['data']['text/plain']
169 text = v5c['data']['text/plain']
170 self.assertEqual(text, '\n'.join([v4c['definition'], v4c['docstring']]))
170 self.assertEqual(text, '\n'.join([v4c['definition'], v4c['docstring']]))
171
171
172 def test_kernel_info_reply(self):
173 msg = self.msg("kernel_info_reply", {
174 'language': 'python',
175 'language_version': [2,8,0],
176 'ipython_version': [1,2,3],
177 })
178 v4, v5 = self.adapt(msg)
179 v4c = v4['content']
180 v5c = v5['content']
181 self.assertEqual(v5c, {
182 'protocol_version': '4.1',
183 'implementation': 'ipython',
184 'implementation_version': '1.2.3',
185 'language_info': {
186 'name': 'python',
187 'version': '2.8.0',
188 },
189 'banner' : '',
190 })
191
172 # iopub channel
192 # iopub channel
173
193
174 def test_display_data(self):
194 def test_display_data(self):
@@ -305,6 +325,29 b' class V5toV4TestCase(AdapterTest):'
305 self.assertEqual(sorted(v4c), ['found', 'oname'])
325 self.assertEqual(sorted(v4c), ['found', 'oname'])
306 self.assertEqual(v4c['found'], False)
326 self.assertEqual(v4c['found'], False)
307
327
328 def test_kernel_info_reply(self):
329 msg = self.msg("kernel_info_reply", {
330 'protocol_version': '5.0',
331 'implementation': 'ipython',
332 'implementation_version': '1.2.3',
333 'language_info': {
334 'name': 'python',
335 'version': '2.8.0',
336 'mimetype': 'text/x-python',
337 },
338 'banner' : 'the banner',
339 })
340 v5, v4 = self.adapt(msg)
341 v4c = v4['content']
342 v5c = v5['content']
343 info = v5c['language_info']
344 self.assertEqual(v4c, {
345 'protocol_version': [5,0],
346 'language': 'python',
347 'language_version': [2,8,0],
348 'ipython_version': [1,2,3],
349 })
350
308 # iopub channel
351 # iopub channel
309
352
310 def test_display_data(self):
353 def test_display_data(self):
@@ -69,9 +69,10 b' class IPythonKernel(KernelBase):'
69 # Kernel info fields
69 # Kernel info fields
70 implementation = 'ipython'
70 implementation = 'ipython'
71 implementation_version = release.version
71 implementation_version = release.version
72 language = 'python'
72 language_info = {
73 language_version = sys.version.split()[0]
73 'name': 'python',
74 language_info = {'mimetype': 'text/x-python',
74 'version': sys.version.split()[0],
75 'mimetype': 'text/x-python',
75 'codemirror_mode': {'name': 'ipython',
76 'codemirror_mode': {'name': 'ipython',
76 'version': sys.version_info[0]},
77 'version': sys.version_info[0]},
77 'pygments_lexer': 'ipython%d' % (3 if PY3 else 2),
78 'pygments_lexer': 'ipython%d' % (3 if PY3 else 2),
@@ -455,8 +455,6 b' class Kernel(SingletonConfigurable):'
455 'protocol_version': release.kernel_protocol_version,
455 'protocol_version': release.kernel_protocol_version,
456 'implementation': self.implementation,
456 'implementation': self.implementation,
457 'implementation_version': self.implementation_version,
457 'implementation_version': self.implementation_version,
458 'language': self.language,
459 'language_version': self.language_version,
460 'language_info': self.language_info,
458 'language_info': self.language_info,
461 'banner': self.banner,
459 'banner': self.banner,
462 }
460 }
@@ -674,19 +674,20 b' Message type: ``kernel_info_reply``::'
674 # Implementation version number.
674 # Implementation version number.
675 # The version number of the kernel's implementation
675 # The version number of the kernel's implementation
676 # (e.g. IPython.__version__ for the IPython kernel)
676 # (e.g. IPython.__version__ for the IPython kernel)
677 'implementation_version': 'X.Y.Z',
677 'implementation_version': 'X.Y.Z',
678
679 # Programming language in which kernel is implemented.
680 # Kernel included in IPython returns 'python'.
681 'language': str,
682
683 # Language version number.
684 # It is Python version number (e.g., '2.7.3') for the kernel
685 # included in IPython.
686 'language_version': 'X.Y.Z',
687
678
688 # Information about the language of code for the kernel
679 # Information about the language of code for the kernel
689 'language_info': {
680 'language_info': {
681 # Name of the programming language in which kernel is implemented.
682 # Kernel included in IPython returns 'python'.
683 'name': str,
684
685 # Language version number.
686 # It is Python version number (e.g., '2.7.3') for the kernel
687 # included in IPython.
688 'version': 'X.Y.Z',
689
690 # mimetype for script files in this language
690 'mimetype': str,
691 'mimetype': str,
691
692
692 # Pygments lexer, for highlighting
693 # Pygments lexer, for highlighting
@@ -725,6 +726,14 b' and `codemirror modes <http://codemirror.net/mode/index.html>`_ for those fields'
725 ``language_info``, ``implementation``, ``implementation_version``, ``banner``
726 ``language_info``, ``implementation``, ``implementation_version``, ``banner``
726 and ``help_links`` keys are added.
727 and ``help_links`` keys are added.
727
728
729 .. versionchanged:: 5.0
730
731 ``language_version`` moved to ``language_info.version``
732
733 .. versionchanged:: 5.0
734
735 ``language`` moved to ``language_info.name``
736
728 .. _msging_shutdown:
737 .. _msging_shutdown:
729
738
730 Kernel shutdown
739 Kernel shutdown
General Comments 0
You need to be logged in to leave comments. Login now