##// END OF EJS Templates
Improve assignment regex to match more tuple unpacking syntax...
Thomas Kluyver -
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
520 assign_system_re = re.compile(r'(?P<lhs>(\s*)([\w\.]+)((\s*,\s*[\w\.]+)*))'
521 r'\s*=\s*!\s*(?P<cmd>.*)')
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 '''
528
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):
General Comments 0
You need to be logged in to leave comments. Login now