##// END OF EJS Templates
s/object_info_request/inspect_request
MinRK -
Show More
@@ -218,7 +218,7 b' var IPython = (function (IPython) {'
218 218
219 219 Tooltip.prototype._request_tooltip = function (cell, text, cursor_pos) {
220 220 var callbacks = $.proxy(this._show, this);
221 var msg_id = cell.kernel.object_info(text, cursor_pos, callbacks);
221 var msg_id = cell.kernel.inspect(text, cursor_pos, callbacks);
222 222 };
223 223
224 224 // make an imediate completion request
@@ -246,7 +246,7 b' var IPython = (function (IPython) {'
246 246 * Get kernel info
247 247 *
248 248 * @param callback {function}
249 * @method object_info
249 * @method kernel_info
250 250 *
251 251 * When calling this method, pass a callback function that expects one argument.
252 252 * The callback will be passed the complete `kernel_info_reply` message documented
@@ -266,13 +266,13 b' var IPython = (function (IPython) {'
266 266 * @param code {string}
267 267 * @param cursor_pos {integer}
268 268 * @param callback {function}
269 * @method object_info
269 * @method inspect
270 270 *
271 271 * When calling this method, pass a callback function that expects one argument.
272 * The callback will be passed the complete `object_info_reply` message documented
272 * The callback will be passed the complete `inspect_reply` message documented
273 273 * [here](http://ipython.org/ipython-doc/dev/development/messaging.html#object-information)
274 274 */
275 Kernel.prototype.object_info = function (code, cursor_pos, callback) {
275 Kernel.prototype.inspect = function (code, cursor_pos, callback) {
276 276 var callbacks;
277 277 if (callback) {
278 278 callbacks = { shell : { reply : callback } };
@@ -283,7 +283,7 b' var IPython = (function (IPython) {'
283 283 cursor_pos : cursor_pos,
284 284 detail_level : 0,
285 285 };
286 return this.send_shell_message("object_info_request", content, callbacks);
286 return this.send_shell_message("inspect_request", content, callbacks);
287 287 };
288 288
289 289 /**
@@ -186,7 +186,7 b' class ShellChannel(ZMQSocketChannel):'
186 186 proxy_methods = [
187 187 'execute',
188 188 'complete',
189 'object_info',
189 'inspect',
190 190 'history',
191 191 'kernel_info',
192 192 'shutdown',
@@ -290,7 +290,7 b' class ShellChannel(ZMQSocketChannel):'
290 290 self._queue_send(msg)
291 291 return msg['header']['msg_id']
292 292
293 def object_info(self, code, cursor_pos=0, detail_level=0):
293 def inspect(self, code, cursor_pos=0, detail_level=0):
294 294 """Get metadata information about an object in the kernel's namespace.
295 295
296 296 It is up to the kernel to determine the appropriate object to inspect.
@@ -312,7 +312,7 b' class ShellChannel(ZMQSocketChannel):'
312 312 content = dict(code=code, cursor_pos=cursor_pos,
313 313 detail_level=detail_level,
314 314 )
315 msg = self.session.msg('object_info_request', content)
315 msg = self.session.msg('inspect_request', content)
316 316 self._queue_send(msg)
317 317 return msg['header']['msg_id']
318 318
@@ -46,7 +46,7 b' class ShellChannelABC(ChannelABC):'
46 46 pass
47 47
48 48 @abc.abstractmethod
49 def object_info(self, oname, detail_level=0):
49 def inspect(self, oname, detail_level=0):
50 50 pass
51 51
52 52 @abc.abstractmethod
@@ -73,7 +73,7 b' class InProcessShellChannel(InProcessChannel):'
73 73 proxy_methods = [
74 74 'execute',
75 75 'complete',
76 'object_info',
76 'inspect',
77 77 'history',
78 78 'shutdown',
79 79 'kernel_info',
@@ -100,11 +100,11 b' class InProcessShellChannel(InProcessChannel):'
100 100 self._dispatch_to_kernel(msg)
101 101 return msg['header']['msg_id']
102 102
103 def object_info(self, code, cursor_pos=0, detail_level=0):
103 def inspect(self, code, cursor_pos=0, detail_level=0):
104 104 content = dict(code=code, cursor_pos=cursor_pos,
105 105 detail_level=detail_level,
106 106 )
107 msg = self.client.session.msg('object_info_request', content)
107 msg = self.client.session.msg('inspect_request', content)
108 108 self._dispatch_to_kernel(msg)
109 109 return msg['header']['msg_id']
110 110
@@ -68,7 +68,7 b' class InProcessKernelManagerTestCase(unittest.TestCase):'
68 68 self.assertEqual(sorted(msg['content']['matches']),
69 69 ['my_bar', 'my_baz'])
70 70
71 def test_object_info(self):
71 def test_inspect(self):
72 72 """ Does requesting object information from an in-process kernel work?
73 73 """
74 74 km = InProcessKernelManager()
@@ -76,9 +76,9 b' class InProcessKernelManagerTestCase(unittest.TestCase):'
76 76 kc = BlockingInProcessKernelClient(kernel=km.kernel)
77 77 kc.start_channels()
78 78 km.kernel.shell.user_ns['foo'] = 1
79 kc.object_info('foo')
79 kc.inspect('foo')
80 80 msg = kc.get_shell_msg()
81 self.assertEqual(msg['header']['msg_type'], 'object_info_reply')
81 self.assertEqual(msg['header']['msg_type'], 'inspect_reply')
82 82 content = msg['content']
83 83 assert content['found']
84 84 self.assertEqual(content['name'], 'foo')
@@ -120,7 +120,7 b' class ExecuteReplyError(Reference):'
120 120 traceback = List(Unicode)
121 121
122 122
123 class OInfoReply(MimeBundle):
123 class InspectReply(MimeBundle):
124 124 name = Unicode()
125 125 found = Bool()
126 126
@@ -174,7 +174,7 b' class ExecuteResult(MimeBundle):'
174 174
175 175 references = {
176 176 'execute_reply' : ExecuteReply(),
177 'object_info_reply' : OInfoReply(),
177 'inspect_reply' : InspectReply(),
178 178 'status' : Status(),
179 179 'complete_reply' : CompleteReply(),
180 180 'kernel_info_reply': KernelInfoReply(),
@@ -297,9 +297,9 b' def test_user_expressions_fail():'
297 297 def test_oinfo():
298 298 flush_channels()
299 299
300 msg_id = KC.object_info('a')
300 msg_id = KC.inspect('a')
301 301 reply = KC.get_shell_msg(timeout=TIMEOUT)
302 validate_message(reply, 'object_info_reply', msg_id)
302 validate_message(reply, 'inspect_reply', msg_id)
303 303
304 304
305 305 def test_oinfo_found():
@@ -307,9 +307,9 b' def test_oinfo_found():'
307 307
308 308 msg_id, reply = execute(code='a=5')
309 309
310 msg_id = KC.object_info('a')
310 msg_id = KC.inspect('a')
311 311 reply = KC.get_shell_msg(timeout=TIMEOUT)
312 validate_message(reply, 'object_info_reply', msg_id)
312 validate_message(reply, 'inspect_reply', msg_id)
313 313 content = reply['content']
314 314 assert content['found']
315 315 nt.assert_equal(content['name'], 'a')
@@ -323,9 +323,9 b' def test_oinfo_detail():'
323 323
324 324 msg_id, reply = execute(code='ip=get_ipython()')
325 325
326 msg_id = KC.object_info('ip.object_inspect', cursor_pos=10, detail_level=1)
326 msg_id = KC.inspect('ip.object_inspect', cursor_pos=10, detail_level=1)
327 327 reply = KC.get_shell_msg(timeout=TIMEOUT)
328 validate_message(reply, 'object_info_reply', msg_id)
328 validate_message(reply, 'inspect_reply', msg_id)
329 329 content = reply['content']
330 330 assert content['found']
331 331 nt.assert_equal(content['name'], 'ip.object_inspect')
@@ -337,9 +337,9 b' def test_oinfo_detail():'
337 337 def test_oinfo_not_found():
338 338 flush_channels()
339 339
340 msg_id = KC.object_info('dne')
340 msg_id = KC.inspect('dne')
341 341 reply = KC.get_shell_msg(timeout=TIMEOUT)
342 validate_message(reply, 'object_info_reply', msg_id)
342 validate_message(reply, 'inspect_reply', msg_id)
343 343 content = reply['content']
344 344 nt.assert_false(content['found'])
345 345
@@ -159,7 +159,7 b' class Kernel(Configurable):'
159 159
160 160 # Build dict of handlers for message types
161 161 msg_types = [ 'execute_request', 'complete_request',
162 'object_info_request', 'history_request',
162 'inspect_request', 'history_request',
163 163 'kernel_info_request',
164 164 'connect_request', 'shutdown_request',
165 165 'apply_request',
@@ -503,7 +503,7 b' class Kernel(Configurable):'
503 503 matches, parent, ident)
504 504 self.log.debug("%s", completion_msg)
505 505
506 def object_info_request(self, stream, ident, parent):
506 def inspect_request(self, stream, ident, parent):
507 507 content = parent['content']
508 508
509 509 name = token_at_cursor(content['code'], content['cursor_pos'])
@@ -522,7 +522,7 b' class Kernel(Configurable):'
522 522 reply_content['data']['text/plain'] = info_text
523 523 # Before we send this object over, we scrub it for JSON usage
524 524 reply_content = json_clean(reply_content)
525 msg = self.session.send(stream, 'object_info_reply',
525 msg = self.session.send(stream, 'inspect_reply',
526 526 reply_content, parent, ident)
527 527 self.log.debug("%s", msg)
528 528
@@ -113,7 +113,7 b' def test_embed_kernel_basic():'
113 113
114 114 with setup_kernel(cmd) as client:
115 115 # oinfo a (int)
116 msg_id = client.object_info('a')
116 msg_id = client.inspect('a')
117 117 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
118 118 content = msg['content']
119 119 nt.assert_true(content['found'])
@@ -124,7 +124,7 b' def test_embed_kernel_basic():'
124 124 nt.assert_equal(content['status'], u'ok')
125 125
126 126 # oinfo c (should be 10)
127 msg_id = client.object_info('c')
127 msg_id = client.inspect('c')
128 128 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
129 129 content = msg['content']
130 130 nt.assert_true(content['found'])
@@ -145,7 +145,7 b' def test_embed_kernel_namespace():'
145 145
146 146 with setup_kernel(cmd) as client:
147 147 # oinfo a (int)
148 msg_id = client.object_info('a')
148 msg_id = client.inspect('a')
149 149 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
150 150 content = msg['content']
151 151 nt.assert_true(content['found'])
@@ -153,7 +153,7 b' def test_embed_kernel_namespace():'
153 153 nt.assert_in(u'5', text)
154 154
155 155 # oinfo b (str)
156 msg_id = client.object_info('b')
156 msg_id = client.inspect('b')
157 157 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
158 158 content = msg['content']
159 159 nt.assert_true(content['found'])
@@ -161,7 +161,7 b' def test_embed_kernel_namespace():'
161 161 nt.assert_in(u'hi there', text)
162 162
163 163 # oinfo c (undefined)
164 msg_id = client.object_info('c')
164 msg_id = client.inspect('c')
165 165 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
166 166 content = msg['content']
167 167 nt.assert_false(content['found'])
@@ -183,7 +183,7 b' def test_embed_kernel_reentrant():'
183 183
184 184 with setup_kernel(cmd) as client:
185 185 for i in range(5):
186 msg_id = client.object_info('count')
186 msg_id = client.inspect('count')
187 187 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
188 188 content = msg['content']
189 189 nt.assert_true(content['found'])
@@ -10,7 +10,7 b' def test_ipython_start_kernel_userns():'
10 10 'start_kernel(user_ns=ns)')
11 11
12 12 with setup_kernel(cmd) as client:
13 msg_id = client.object_info('tre')
13 msg_id = client.inspect('tre')
14 14 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
15 15 content = msg['content']
16 16 assert content['found']
@@ -22,7 +22,7 b' def test_ipython_start_kernel_userns():'
22 22 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
23 23 content = msg['content']
24 24 nt.assert_equal(content['status'], u'ok')
25 msg_id = client.object_info('usermod')
25 msg_id = client.inspect('usermod')
26 26 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
27 27 content = msg['content']
28 28 assert content['found']
@@ -40,7 +40,7 b' def test_ipython_start_kernel_no_userns():'
40 40 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
41 41 content = msg['content']
42 42 nt.assert_equal(content['status'], u'ok')
43 msg_id = client.object_info('usermod')
43 msg_id = client.inspect('usermod')
44 44 msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
45 45 content = msg['content']
46 46 assert content['found']
@@ -1,5 +1,6 b''
1 1 # Standard library imports
2 2 import re
3 import textwrap
3 4 from unicodedata import category
4 5
5 6 # System library imports
@@ -122,21 +123,15 b' class CallTipWidget(QtGui.QLabel):'
122 123 # 'CallTipWidget' interface
123 124 #--------------------------------------------------------------------------
124 125
125 def show_call_info(self, call_line=None, doc=None, maxlines=20):
126 """ Attempts to show the specified call line and docstring at the
127 current cursor location. The docstring is possibly truncated for
128 length.
129 """
130 if doc:
131 match = re.match("(?:[^\n]*\n){%i}" % maxlines, doc)
132 if match:
133 doc = doc[:match.end()] + '\n[Documentation continues...]'
134 else:
135 doc = ''
126 def show_inspect_data(self, content, maxlines=20):
127 """Show inspection data as a tooltip"""
128 data = content.get('data', {})
129 text = data.get('text/plain', '')
130 match = re.match("(?:[^\n]*\n){%i}" % maxlines, text)
131 if match:
132 text = text[:match.end()] + '\n[Documentation continues...]'
136 133
137 if call_line:
138 doc = '\n\n'.join([call_line, doc])
139 return self.show_tip(self._format_tooltip(doc))
134 return self.show_tip(self._format_tooltip(text))
140 135
141 136 def show_tip(self, tip):
142 137 """ Attempts to show the specified tip at the current cursor location.
@@ -247,8 +242,8 b' class CallTipWidget(QtGui.QLabel):'
247 242 QtGui.qApp.topLevelAt(QtGui.QCursor.pos()) != self):
248 243 self._hide_timer.start(300, self)
249 244
250 def _format_tooltip(self,doc):
251 import textwrap
245 def _format_tooltip(self, doc):
246 doc = re.sub(r'\033\[(\d|;)+?m', '', doc)
252 247
253 248 # make sure a long argument list does not make
254 249 # the first row overflow the width of the actual tip body
@@ -505,9 +505,8 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
505 505 self._kernel_restarted_message(died=died)
506 506 self.reset()
507 507
508 def _handle_object_info_reply(self, rep):
509 """ Handle replies for call tips.
510 """
508 def _handle_inspect_reply(self, rep):
509 """Handle replies for call tips."""
511 510 self.log.debug("oinfo: %s", rep.get('content', ''))
512 511 cursor = self._get_cursor()
513 512 info = self._request_info.get('call_tip')
@@ -518,16 +517,8 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
518 517 # syntax-highlight it ourselves for nicer formatting in the
519 518 # calltip.
520 519 content = rep['content']
521 # if this is from pykernel, 'docstring' will be the only key
522 if content.get('ismagic', False):
523 # Don't generate a call-tip for magics. Ideally, we should
524 # generate a tooltip, but not on ( like we do for actual
525 # callables.
526 call_info, doc = None, None
527 else:
528 call_info, doc = call_tip(content, format_call=True)
529 if call_info or doc:
530 self._call_tip_widget.show_call_info(call_info, doc)
520 if content.get('status') == 'ok':
521 self._call_tip_widget.show_inspect_data(content)
531 522
532 523 def _handle_execute_result(self, msg):
533 524 """ Handle display hook output.
@@ -734,7 +725,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
734 725 cursor_pos = self._get_input_buffer_cursor_pos()
735 726 code = self.input_buffer
736 727 # Send the metadata request to the kernel
737 msg_id = self.kernel_client.object_info(code, cursor_pos)
728 msg_id = self.kernel_client.inspect(code, cursor_pos)
738 729 pos = self._get_cursor().position()
739 730 self._request_info['call_tip'] = self._CallTipRequest(msg_id, pos)
740 731 return True
@@ -57,7 +57,7 b' class QtShellChannelMixin(ChannelQObject):'
57 57 # Emitted when a reply has been received for the corresponding request type.
58 58 execute_reply = QtCore.Signal(object)
59 59 complete_reply = QtCore.Signal(object)
60 object_info_reply = QtCore.Signal(object)
60 inspect_reply = QtCore.Signal(object)
61 61 history_reply = QtCore.Signal(object)
62 62
63 63 #---------------------------------------------------------------------------
General Comments 0
You need to be logged in to leave comments. Login now