Compilation, Evaluation, & Execution (xonsh.execer)

Implements the xonsh executer.

class xonsh.execer.Execer(filename='<xonsh-code>', debug_level=0, parser_args=None, unload=True, xonsh_ctx=None, scriptcache=True, cacheall=False)[source]

Executes xonsh code in a context.

Parameters
filenamestr, optional

File we are to execute.

debug_levelint, optional

Debugging level to use in lexing and parsing.

parser_argsdict, optional

Arguments to pass down to the parser.

unloadbool, optional

Whether or not to unload xonsh builtins upon deletion.

xonsh_ctxdict or None, optional

Xonsh xontext to load as builtins.__xonsh__.ctx

scriptcachebool, optional

Whether or not to use a precompiled bytecode cache when execing code, default: True.

cacheallbool, optional

Whether or not to cache all xonsh code, and not just files. If this is set to true, it will cache command line input too, default: False.

compile(self, input, mode='exec', glbs=None, locs=None, stacklevel=2, filename=None, transform=True)[source]

Compiles xonsh code into a Python code object, which may then be execed or evaled.

eval(self, input, glbs=None, locs=None, stacklevel=2, filename=None, transform=True)[source]

Evaluates (and returns) xonsh code.

exec(self, input, mode='exec', glbs=None, locs=None, stacklevel=2, filename=None, transform=True)[source]

Execute xonsh code.

parse(self, input, ctx, mode='exec', filename=None, transform=True)[source]

Parses xonsh code in a context-aware fashion. For context-free parsing, please use the Parser class directly or pass in transform=False.