Abstract Syntax Tree (xonsh.ast)

The xonsh abstract syntax tree node.

class xonsh.ast.CtxAwareTransformer(parser)[source]

Transforms a xonsh AST based to use subprocess calls when the first name in an expression statement is not known in the context. This assumes that the expression statement is instead parseable as a subprocess.

Parameters:

parser : xonsh.Parser

A parse instance to try to parse suprocess statements with.

ctxadd(value)[source]

Adds a value the most recent context.

ctxremove(value)[source]

Removes a value the most recent context.

ctxupdate(iterable)[source]

Updated the most recent context.

ctxvisit(node, input, ctx, mode='exec')[source]

Transforms the node in a context-dependent way.

Parameters:

node : ast.AST

A syntax tree to transform.

input : str

The input code in string format.

ctx : dict

The root context to use.

Returns:

node : ast.AST

The transformed node.

generic_visit(node)
is_in_scope(node)[source]

Determines whether or not the current node is in scope.

try_subproc_toks(node)[source]

Tries to parse the line of the node as a subprocess.

visit(node)

Visit a node.

visit_Assign(node)[source]
visit_ClassDef(node)[source]
visit_Delete(node)[source]
visit_Expr(node)[source]
visit_Expression(node)[source]
visit_For(node)[source]
visit_FunctionDef(node)[source]
visit_Global(node)[source]
visit_Import(node)[source]
visit_ImportFrom(node)[source]
visit_Try(node)[source]
visit_With(node)[source]
xonsh.ast.leftmostname(node)[source]

Attempts to find the first name in the tree.

This Page