This is a development version (latest) and may be unstable. Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython latest / IPython / core / prefilter / PrefilterManager

MetaHasTraits

IPython.core.prefilter:PrefilterManager

source: /IPython/core/prefilter.py :78

Signature

def   PrefilterManager ( shell = None ** kwargs )

Members

Summary

Main prefilter component.

Extended Summary

The IPython prefilter is run on all user input before it is run. The prefilter consumes lines of input and produces transformed lines of input.

The implementation consists of two phases:

  • Transformers

  • Checkers and handlers

Over time, we plan on deprecating the checkers and handlers and doing everything in the transformers.

The transformers are instances of PrefilterTransformer and have a single method transform that takes a line and returns a transformed line. The transformation can be accomplished using any tool, but our current ones use regular expressions for speed.

After all the transformers have been run, the line is fed to the checkers, which are instances of PrefilterChecker. The line is passed to the check method, which either returns None or a PrefilterHandler instance. If None is returned, the other checkers are tried. If an PrefilterHandler instance is returned, the line is passed to the handle method of the returned handler and no further checkers are tried.

Both transformers and checkers have a priority attribute, that determines the order in which they are called. Smaller priorities are tried first.

Both transformers and checkers also have enabled attribute, which is a boolean that determines if the instance is used.

Users or developers can change the priority or enabled attribute of transformers or checkers, but they must call the sort_checkers or sort_transformers method after changing the priority.

Aliases

  • IPython.core.interactiveshell.PrefilterManager