##// END OF EJS Templates
Avoid trying to compile the code after each line
Thomas Kluyver -
Show More
@@ -699,41 +699,55 b' class IPythonInputSplitter(InputSplitter):'
699 699 # flush the buffer.
700 700 self._store(lines, self._buffer_raw, 'source_raw')
701 701
702 transformed_lines_list = []
702 703 for line in lines_list:
703 out = self.push_line(line)
704 transformed = self._transform_line(line)
705 if transformed is not None:
706 transformed_lines_list.append(transformed)
704 707
705 return out
706
707 def push_line(self, line):
708 buf = self._buffer
708 if transformed_lines_list:
709 transformed_lines = '\n'.join(transformed_lines_list)
710 return super(IPythonInputSplitter, self).push(transformed_lines)
711 else:
712 # Got nothing back from transformers - they must be waiting for
713 # more input.
714 return False
715
716 def _transform_line(self, line):
717 """Push a line of input code through the various transformers.
709 718
719 Returns any output from the transformers, or None if a transformer
720 is accumulating lines.
721
722 Sets self.transformer_accumulating as a side effect.
723 """
710 724 def _accumulating(dbg):
711 725 #print(dbg)
712 726 self.transformer_accumulating = True
713 return False
714
727 return None
728
715 729 for transformer in self.physical_line_transforms:
716 730 line = transformer.push(line)
717 731 if line is None:
718 732 return _accumulating(transformer)
719
733
720 734 if not self.within_python_line:
721 735 line = self.assemble_logical_lines.push(line)
722 736 if line is None:
723 return _accumulating('acc logical line')
724
737 return _accumulating('acc logical line')
738
725 739 for transformer in self.logical_line_transforms:
726 740 line = transformer.push(line)
727 741 if line is None:
728 742 return _accumulating(transformer)
729
743
730 744 line = self.assemble_python_lines.push(line)
731 745 if line is None:
732 746 self.within_python_line = True
733 747 return _accumulating('acc python line')
734 748 else:
735 749 self.within_python_line = False
736
750
737 751 for transformer in self.python_line_transforms:
738 752 line = transformer.push(line)
739 753 if line is None:
@@ -741,4 +755,5 b' class IPythonInputSplitter(InputSplitter):'
741 755
742 756 #print("transformers clear") #debug
743 757 self.transformer_accumulating = False
744 return super(IPythonInputSplitter, self).push(line)
758 return line
759
General Comments 0
You need to be logged in to leave comments. Login now