Transforms a cell of input code
(self, cell: str)
| 583 | "%d iterations. Aborting." % TRANSFORM_LOOP_LIMIT) |
| 584 | |
| 585 | def transform_cell(self, cell: str) -> str: |
| 586 | """Transforms a cell of input code""" |
| 587 | if not cell.endswith('\n'): |
| 588 | cell += '\n' # Ensure the cell has a trailing newline |
| 589 | lines = cell.splitlines(keepends=True) |
| 590 | for transform in self.cleanup_transforms + self.line_transforms: |
| 591 | lines = transform(lines) |
| 592 | |
| 593 | lines = self.do_token_transforms(lines) |
| 594 | return ''.join(lines) |
| 595 | |
| 596 | def check_complete(self, cell: str): |
| 597 | """Return whether a block of code is ready to execute, or should be continued |