Inheritance diagram for IPython.prefilter:
Classes and functions for prefiltering (transforming) a line of user input. This module is responsible, primarily, for breaking the line up into useful pieces and triggering the appropriate handlers in iplib to do the actual transforming work.
Bases: object
A single line of input and associated info.
Includes the following as properties:
Do a full, attribute-walking lookup of the iFun in the various namespaces for the given IPython InteractiveShell instance.
Return a dict with keys: found,obj,ospace,ismagic
Note: can cause state changes because of calling getattr, but should only be run if autocall is on and if the line hasn’t matched any other, less dangerous handlers.
Does cache the results of the call, so can be called multiple times without worrying about further damaging state.
Check if the initital identifier on the line is an alias.
Check to see if user is assigning to a var for the first time, in which case we want to avoid any sort of automagic / autocall games.
This allows users to assign to either alias or magic names true python variables (the magic/alias systems always take second seat to true python code). E.g. ls=’hi’, or ls,that=1,2
Check if the initial word/function is callable and autocall is on.
If the iFun is magic, and automagic is on, run it. Note: normal, non-auto magic would already have been triggered via ‘%’ in check_esc_chars. This just checks for automagic. Also, before triggering the magic handler, make sure that there is nothing in the user namespace which could shadow it.
Emacs ipython-mode tags certain input lines.
Check for escape character and return either a handler to handle it, or None if there is no escape char.
Instances of IPyAutocall in user_ns get autocalled immediately
Allow ! and !! in multi-line statements if multi_line_specials is on
If the ‘rest’ of the line begins with a function call or pretty much any python operator, we should simply execute the line (regardless of whether or not there’s a possible autocall expansion). This avoids spurious (and very confusing) geattr() accesses.
Is the given identifier defined in one of the namespaces which shadow the alias and magic namespaces? Note that an identifier is different than iFun, because it can not contain a ‘.’ character.
Call one of the passed-in InteractiveShell’s handler preprocessors, depending on the form of the line. Return the results, which must be a value, even if it’s a blank (‘’).
Split user input into pre-char/whitespace, function part and rest.
Mostly internal to this module, but also used by iplib.expand_aliases, which passes in a shell pattern.