##// END OF EJS Templates
Fix handling of lines like '%%foo?' in cell magic logic.
Fernando Perez -
Show More
@@ -60,7 +60,6 b' Authors'
60 # Distributed under the terms of the BSD License. The full license is in
60 # Distributed under the terms of the BSD License. The full license is in
61 # the file COPYING, distributed as part of this software.
61 # the file COPYING, distributed as part of this software.
62 #-----------------------------------------------------------------------------
62 #-----------------------------------------------------------------------------
63 from __future__ import print_function
64
63
65 #-----------------------------------------------------------------------------
64 #-----------------------------------------------------------------------------
66 # Imports
65 # Imports
@@ -598,7 +597,6 b' def _make_help_call(target, esc, lspace, next_input=None):'
598 else 'psearch' if '*' in target \
597 else 'psearch' if '*' in target \
599 else 'pinfo'
598 else 'pinfo'
600 arg = " ".join([method, target])
599 arg = " ".join([method, target])
601
602 if next_input is None:
600 if next_input is None:
603 return '%sget_ipython().magic(%r)' % (lspace, arg)
601 return '%sget_ipython().magic(%r)' % (lspace, arg)
604 else:
602 else:
@@ -608,7 +606,7 b' def _make_help_call(target, esc, lspace, next_input=None):'
608
606
609 _initial_space_re = re.compile(r'\s*')
607 _initial_space_re = re.compile(r'\s*')
610
608
611 _help_end_re = re.compile(r"""(%?
609 _help_end_re = re.compile(r"""(%{0,2}
612 [a-zA-Z_*][\w*]* # Variable name
610 [a-zA-Z_*][\w*]* # Variable name
613 (\.[a-zA-Z_*][\w*]*)* # .etc.etc
611 (\.[a-zA-Z_*][\w*]*)* # .etc.etc
614 )
612 )
@@ -841,7 +839,8 b' class IPythonInputSplitter(InputSplitter):'
841
839
842 # If the entire input block is a cell magic, return after handling it
840 # If the entire input block is a cell magic, return after handling it
843 # as the rest of the transformation logic should be skipped.
841 # as the rest of the transformation logic should be skipped.
844 if lines.startswith('%%'):
842 if lines.startswith('%%') and not \
843 (len(lines.splitlines()) == 1 and lines.endswith('?')):
845 return self._handle_cell_magic(lines)
844 return self._handle_cell_magic(lines)
846
845
847 # In line mode, a cell magic can arrive in separate pieces
846 # In line mode, a cell magic can arrive in separate pieces
@@ -455,7 +455,8 b' syntax = \\'
455 (u'?x1', "get_ipython().magic({u}'pinfo x1')"),
455 (u'?x1', "get_ipython().magic({u}'pinfo x1')"),
456 (u'??x2', "get_ipython().magic({u}'pinfo2 x2')"),
456 (u'??x2', "get_ipython().magic({u}'pinfo2 x2')"),
457 (u'?a.*s', "get_ipython().magic({u}'psearch a.*s')"),
457 (u'?a.*s', "get_ipython().magic({u}'psearch a.*s')"),
458 (u'?%hist', "get_ipython().magic({u}'pinfo %hist')"),
458 (u'?%hist1', "get_ipython().magic({u}'pinfo %hist1')"),
459 (u'?%%hist2', "get_ipython().magic({u}'pinfo %%hist2')"),
459 (u'?abc = qwe', "get_ipython().magic({u}'pinfo abc')"),
460 (u'?abc = qwe', "get_ipython().magic({u}'pinfo abc')"),
460 ]],
461 ]],
461
462
@@ -463,7 +464,10 b' syntax = \\'
463 [(i,py3compat.u_format(o)) for i,o in \
464 [(i,py3compat.u_format(o)) for i,o in \
464 [ (u'x3?', "get_ipython().magic({u}'pinfo x3')"),
465 [ (u'x3?', "get_ipython().magic({u}'pinfo x3')"),
465 (u'x4??', "get_ipython().magic({u}'pinfo2 x4')"),
466 (u'x4??', "get_ipython().magic({u}'pinfo2 x4')"),
466 (u'%hist?', "get_ipython().magic({u}'pinfo %hist')"),
467 (u'%hist1?', "get_ipython().magic({u}'pinfo %hist1')"),
468 (u'%hist2??', "get_ipython().magic({u}'pinfo2 %hist2')"),
469 (u'%%hist3?', "get_ipython().magic({u}'pinfo %%hist3')"),
470 (u'%%hist4??', "get_ipython().magic({u}'pinfo2 %%hist4')"),
467 (u'f*?', "get_ipython().magic({u}'psearch f*')"),
471 (u'f*?', "get_ipython().magic({u}'psearch f*')"),
468 (u'ax.*aspe*?', "get_ipython().magic({u}'psearch ax.*aspe*')"),
472 (u'ax.*aspe*?', "get_ipython().magic({u}'psearch ax.*aspe*')"),
469 (u'a = abc?', "get_ipython().set_next_input({u}'a = abc');"
473 (u'a = abc?', "get_ipython().set_next_input({u}'a = abc');"
General Comments 0
You need to be logged in to leave comments. Login now