Note
This documentation is for a development version of IPython. There may be significant differences from the latest stable release (1.2.1).
Input transformer classes to support IPython special syntax.
This includes the machinery to recognise and transform %magic commands, !system commands, help? querying, prompt stripping, and so forth.
Bases: abc._NewBase
Abstract base class for line-based input transformers.
Send a line of input to the transformer, returning the transformed input or None if the transformer is waiting for more input.
Must be overridden by subclasses.
Implementations may raise SyntaxError if the input is invalid. No other exceptions may be raised.
Return, transformed any lines that the transformer has accumulated, and reset its internal state.
Must be overridden by subclasses.
Can be used by subclasses as a decorator, to return a factory that will allow instantiation with the decorated object.
Bases: IPython.core.inputtransformer.InputTransformer
Wrapper for a stateless input transformer implemented as a function.
Send a line of input to the transformer, returning the transformed input.
No-op - exists for compatibility.
Bases: IPython.core.inputtransformer.InputTransformer
Wrapper for an input transformer implemented as a coroutine.
Send a line of input to the transformer, returning the transformed input or None if the transformer is waiting for more input.
Return, transformed any lines that the transformer has accumulated, and reset its internal state.
Bases: IPython.core.inputtransformer.InputTransformer
Wrapper for a token-based input transformer.
func should accept a list of tokens (5-tuples, see tokenize docs), and return an iterable which can be passed to tokenize.untokenize().
Bases: IPython.core.inputtransformer.TokenInputTransformer
Join lines following explicit line continuations ()
Transform escaped commands - %magic, !system, ?help + various autocalls.
Indicate whether an input line has (i.e. ends in, or is) a comment.
This uses tokenize, so it can distinguish comments from # inside strings.
Parameters: | src : string
|
---|---|
Returns: | comment : bool
|
Indicates whether or not an input line ends in a comment or within a multiline string.
Parameters: | src : string
|
---|---|
Returns: | comment : bool
|
Translate lines with ?/?? at the end
Captures & transforms cell magics.
After a cell magic is started, this stores up any lines it gets until it is reset (sent None).
Strip the >>>/... prompts of the Python interactive shell.
Strip IPython’s In [1]:/...: prompts.
Remove leading indentation.
If the first line starts with a spaces or tabs, the same whitespace will be removed from each following line until it is reset.
Remove encoding comment if found in first two lines
If the first or second line has the # coding: utf-8 comment, it will be removed.
Transform assignment from system commands (e.g. files = !ls)
Transform assignment from magic commands (e.g. a = %who_ls)