##// END OF EJS Templates
Merge pull request #5321 from takluyver/i5305...
Thomas Kluyver -
r15798:9aa711b1 merge
parent child Browse files
Show More
@@ -516,9 +516,17 b' def strip_encoding_cookie():'
516 516 while line is not None:
517 517 line = (yield line)
518 518
519 _assign_pat = \
520 r'''(?P<lhs>(\s*)
521 ([\w\.]+) # Initial identifier
522 (\s*,\s*
523 \*?[\w\.]+)* # Further identifiers for unpacking
524 \s*?,? # Trailing comma
525 )
526 \s*=\s*
527 '''
519 528
520 assign_system_re = re.compile(r'(?P<lhs>(\s*)([\w\.]+)((\s*,\s*[\w\.]+)*))'
521 r'\s*=\s*!\s*(?P<cmd>.*)')
529 assign_system_re = re.compile(r'{}!\s*(?P<cmd>.*)'.format(_assign_pat), re.VERBOSE)
522 530 assign_system_template = '%s = get_ipython().getoutput(%r)'
523 531 @StatelessInputTransformer.wrap
524 532 def assign_from_system(line):
@@ -529,8 +537,7 b' def assign_from_system(line):'
529 537
530 538 return assign_system_template % m.group('lhs', 'cmd')
531 539
532 assign_magic_re = re.compile(r'(?P<lhs>(\s*)([\w\.]+)((\s*,\s*[\w\.]+)*))'
533 r'\s*=\s*%\s*(?P<cmd>.*)')
540 assign_magic_re = re.compile(r'{}%\s*(?P<cmd>.*)'.format(_assign_pat), re.VERBOSE)
534 541 assign_magic_template = '%s = get_ipython().magic(%r)'
535 542 @StatelessInputTransformer.wrap
536 543 def assign_from_magic(line):
@@ -41,16 +41,29 b' syntax = \\'
41 41 [(i,py3compat.u_format(o)) for i,o in \
42 42 [(u'a =! ls', "a = get_ipython().getoutput({u}'ls')"),
43 43 (u'b = !ls', "b = get_ipython().getoutput({u}'ls')"),
44 (u'c= !ls', "c = get_ipython().getoutput({u}'ls')"),
45 (u'd == !ls', u'd == !ls'), # Invalid syntax, but we leave == alone.
44 46 ('x=1', 'x=1'), # normal input is unmodified
45 47 (' ',' '), # blank lines are kept intact
48 # Tuple unpacking
49 (u"a, b = !echo 'a\\nb'", u"a, b = get_ipython().getoutput({u}\"echo 'a\\\\nb'\")"),
50 (u"a,= !echo 'a'", u"a, = get_ipython().getoutput({u}\"echo 'a'\")"),
51 (u"a, *bc = !echo 'a\\nb\\nc'", u"a, *bc = get_ipython().getoutput({u}\"echo 'a\\\\nb\\\\nc'\")"),
52 # Tuple unpacking with regular Python expressions, not our syntax.
53 (u"a, b = range(2)", u"a, b = range(2)"),
54 (u"a, = range(1)", u"a, = range(1)"),
55 (u"a, *bc = range(3)", u"a, *bc = range(3)"),
46 56 ]],
47 57
48 58 assign_magic =
49 59 [(i,py3compat.u_format(o)) for i,o in \
50 60 [(u'a =% who', "a = get_ipython().magic({u}'who')"),
51 61 (u'b = %who', "b = get_ipython().magic({u}'who')"),
62 (u'c= %ls', "c = get_ipython().magic({u}'ls')"),
63 (u'd == %ls', u'd == %ls'), # Invalid syntax, but we leave == alone.
52 64 ('x=1', 'x=1'), # normal input is unmodified
53 65 (' ',' '), # blank lines are kept intact
66 (u"a, b = %foo", u"a, b = get_ipython().magic({u}'foo')"),
54 67 ]],
55 68
56 69 classic_prompt =
General Comments 0
You need to be logged in to leave comments. Login now