xonsh.contexts

Context management tools for xonsh.

class xonsh.contexts.Block[source]

This is a context manager for obtaining a block of lines without actually executing the block. The lines are accessible as the ‘lines’ attribute. This must be used as a macro.

Attributes:
lineslist of str or None

Block lines as if split by str.splitlines(), if available.

glbsMapping or None

Global execution context, ie globals().

locsMapping or None

Local execution context, ie locals().

class xonsh.contexts.Functor(args=(), kwargs=None, rtn='')[source]

This is a context manager that turns the block into a callable object, bound to the execution context it was created in.

Parameters:
argsSequence of str, optional

A tuple of argument names for the functor.

kwargsMapping of str to values or list of item tuples, optional

Keyword argument names and values, if available.

rtnstr, optional

Name of object to return, if available.

Attributes:
funcfunction

The underlying function object. This defaults to none and is set after the the block is exited.