MCPcopy Create free account
hub / github.com/ipython/ipython / IPythonInputSplitter

Class IPythonInputSplitter

IPython/core/inputsplitter.py:533–771  ·  view source on GitHub ↗

An input splitter that recognizes all of IPython's special syntax.

Source from the content-addressed store, hash-verified

531
532
533class IPythonInputSplitter(InputSplitter):
534 """An input splitter that recognizes all of IPython's special syntax."""
535
536 # String with raw, untransformed input.
537 source_raw = ''
538
539 # Flag to track when a transformer has stored input that it hasn't given
540 # back yet.
541 transformer_accumulating = False
542
543 # Flag to track when assemble_python_lines has stored input that it hasn't
544 # given back yet.
545 within_python_line = False
546
547 # Private attributes
548
549 # List with lines of raw input accumulated so far.
550 _buffer_raw = None
551
552 def __init__(self, line_input_checker=True, physical_line_transforms=None,
553 logical_line_transforms=None, python_line_transforms=None):
554 super(IPythonInputSplitter, self).__init__()
555 self._buffer_raw = []
556 self._validate = True
557
558 if physical_line_transforms is not None:
559 self.physical_line_transforms = physical_line_transforms
560 else:
561 self.physical_line_transforms = [
562 leading_indent(),
563 classic_prompt(),
564 ipy_prompt(),
565 cellmagic(end_on_blank_line=line_input_checker),
566 ]
567
568 self.assemble_logical_lines = assemble_logical_lines()
569 if logical_line_transforms is not None:
570 self.logical_line_transforms = logical_line_transforms
571 else:
572 self.logical_line_transforms = [
573 help_end(),
574 escaped_commands(),
575 assign_from_magic(),
576 assign_from_system(),
577 ]
578
579 self.assemble_python_lines = assemble_python_lines()
580 if python_line_transforms is not None:
581 self.python_line_transforms = python_line_transforms
582 else:
583 # We don't use any of these at present
584 self.python_line_transforms = []
585
586 @property
587 def transforms(self):
588 "Quick access to all transformers."
589 return self.physical_line_transforms + \
590 [self.assemble_logical_lines] + self.logical_line_transforms + \

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected