Show More
@@ -699,41 +699,55 b' class IPythonInputSplitter(InputSplitter):' | |||||
699 | # flush the buffer. |
|
699 | # flush the buffer. | |
700 | self._store(lines, self._buffer_raw, 'source_raw') |
|
700 | self._store(lines, self._buffer_raw, 'source_raw') | |
701 |
|
701 | |||
|
702 | transformed_lines_list = [] | |||
702 | for line in lines_list: |
|
703 | for line in lines_list: | |
703 |
|
|
704 | transformed = self._transform_line(line) | |
|
705 | if transformed is not None: | |||
|
706 | transformed_lines_list.append(transformed) | |||
704 |
|
707 | |||
705 | return out |
|
708 | if transformed_lines_list: | |
706 |
|
709 | transformed_lines = '\n'.join(transformed_lines_list) | ||
707 | def push_line(self, line): |
|
710 | return super(IPythonInputSplitter, self).push(transformed_lines) | |
708 | buf = self._buffer |
|
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 | def _accumulating(dbg): |
|
724 | def _accumulating(dbg): | |
711 | #print(dbg) |
|
725 | #print(dbg) | |
712 | self.transformer_accumulating = True |
|
726 | self.transformer_accumulating = True | |
713 |
return |
|
727 | return None | |
714 |
|
728 | |||
715 | for transformer in self.physical_line_transforms: |
|
729 | for transformer in self.physical_line_transforms: | |
716 | line = transformer.push(line) |
|
730 | line = transformer.push(line) | |
717 | if line is None: |
|
731 | if line is None: | |
718 | return _accumulating(transformer) |
|
732 | return _accumulating(transformer) | |
719 |
|
733 | |||
720 | if not self.within_python_line: |
|
734 | if not self.within_python_line: | |
721 | line = self.assemble_logical_lines.push(line) |
|
735 | line = self.assemble_logical_lines.push(line) | |
722 | if line is None: |
|
736 | if line is None: | |
723 |
return _accumulating('acc logical line') |
|
737 | return _accumulating('acc logical line') | |
724 |
|
738 | |||
725 | for transformer in self.logical_line_transforms: |
|
739 | for transformer in self.logical_line_transforms: | |
726 | line = transformer.push(line) |
|
740 | line = transformer.push(line) | |
727 | if line is None: |
|
741 | if line is None: | |
728 | return _accumulating(transformer) |
|
742 | return _accumulating(transformer) | |
729 |
|
743 | |||
730 | line = self.assemble_python_lines.push(line) |
|
744 | line = self.assemble_python_lines.push(line) | |
731 | if line is None: |
|
745 | if line is None: | |
732 | self.within_python_line = True |
|
746 | self.within_python_line = True | |
733 | return _accumulating('acc python line') |
|
747 | return _accumulating('acc python line') | |
734 | else: |
|
748 | else: | |
735 | self.within_python_line = False |
|
749 | self.within_python_line = False | |
736 |
|
750 | |||
737 | for transformer in self.python_line_transforms: |
|
751 | for transformer in self.python_line_transforms: | |
738 | line = transformer.push(line) |
|
752 | line = transformer.push(line) | |
739 | if line is None: |
|
753 | if line is None: | |
@@ -741,4 +755,5 b' class IPythonInputSplitter(InputSplitter):' | |||||
741 |
|
755 | |||
742 | #print("transformers clear") #debug |
|
756 | #print("transformers clear") #debug | |
743 | self.transformer_accumulating = False |
|
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