Transforms a cell of input code
(self, cell: str)
| 723 | "%d iterations. Aborting." % TRANSFORM_LOOP_LIMIT) |
| 724 | |
| 725 | def transform_cell(self, cell: str) -> str: |
| 726 | """Transforms a cell of input code""" |
| 727 | if not cell.endswith('\n'): |
| 728 | cell += '\n' # Ensure the cell has a trailing newline |
| 729 | lines = cell.splitlines(keepends=True) |
| 730 | for transform in self.cleanup_transforms + self.line_transforms: |
| 731 | lines = transform(lines) |
| 732 | |
| 733 | lines = self.do_token_transforms(lines) |
| 734 | return ''.join(lines) |
| 735 | |
| 736 | def check_complete(self, cell: str): |
| 737 | """Return whether a block of code is ready to execute, or should be continued |