Package genshi :: Package template :: Module astutil :: Class ASTCodeGenerator

Class ASTCodeGenerator

object --+
         |
        ASTCodeGenerator

General purpose base class for AST transformations.

Every visitor method can be overridden to return an AST node that has been altered or replaced in some way.

Instance Methods
 
__init__(self, tree)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
visit(self, node)
 
visit_Module(self, node)
 
visit_Interactive(self, node)
 
visit_Suite(self, node)
 
visit_Expression(self, node)
 
visit_arguments(self, node)
 
visit_FunctionDef(self, node)
 
visit_ClassDef(self, node)
 
visit_Return(self, node)
 
visit_Delete(self, node)
 
visit_Assign(self, node)
 
visit_AugAssign(self, node)
 
visit_Print(self, node)
 
visit_For(self, node)
 
visit_While(self, node)
 
visit_If(self, node)
 
visit_With(self, node)
 
visit_Raise(self, node)
 
visit_TryExcept(self, node)
 
visit_ExceptHandler(self, node)
 
visit_excepthandler(self, node)
 
visit_TryFinally(self, node)
 
visit_Assert(self, node)
 
visit_alias(self, node)
 
visit_Import(self, node)
 
visit_ImportFrom(self, node)
 
visit_Exec(self, node)
 
visit_Global(self, node)
 
visit_Expr(self, node)
 
visit_Pass(self, node)
 
visit_Break(self, node)
 
visit_Continue(self, node)
 
with_parens(f)
 
visit_BoolOp(self, node)
 
visit_BinOp(self, node)
 
visit_UnaryOp(self, node)
 
visit_Lambda(self, node)
 
visit_IfExp(self, node)
 
visit_Dict(self, node)
 
visit_ListComp(self, node)
 
visit_GeneratorExp(self, node)
 
visit_Yield(self, node)
 
visit_Compare(self, node)
 
visit_Call(self, node)
 
visit_Repr(self, node)
 
visit_Num(self, node)
 
visit_Str(self, node)
 
visit_Attribute(self, node)
 
visit_Subscript(self, node)
 
visit_Name(self, node)
 
visit_List(self, node)
 
visit_Tuple(self, node)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  bool_operators = {<class '_ast.And'>: 'and', <class '_ast.Or'>...
  binary_operators = {<class '_ast.Add'>: '+', <class '_ast.Sub'...
  unary_operators = {<class '_ast.Invert'>: '~', <class '_ast.No...
  comparision_operators = {<class '_ast.Eq'>: '==', <class '_ast...
Properties

Inherited from object: __class__

Method Details

__init__(self, tree)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

visit_BoolOp(self, node)

 
Decorators:
  • @with_parens

visit_BinOp(self, node)

 
Decorators:
  • @with_parens

visit_Lambda(self, node)

 
Decorators:
  • @with_parens

visit_IfExp(self, node)

 
Decorators:
  • @with_parens

visit_Compare(self, node)

 
Decorators:
  • @with_parens

Class Variable Details

bool_operators

Value:
{<class '_ast.And'>: 'and', <class '_ast.Or'>: 'or'}

binary_operators

Value:
{<class '_ast.Add'>: '+',
 <class '_ast.Sub'>: '-',
 <class '_ast.Mult'>: '*',
 <class '_ast.Div'>: '/',
 <class '_ast.Mod'>: '%',
 <class '_ast.Pow'>: '**',
 <class '_ast.LShift'>: '<<',
 <class '_ast.RShift'>: '>>',
...

unary_operators

Value:
{<class '_ast.Invert'>: '~',
 <class '_ast.Not'>: 'not',
 <class '_ast.UAdd'>: '+',
 <class '_ast.USub'>: '-'}

comparision_operators

Value:
{<class '_ast.Eq'>: '==',
 <class '_ast.NotEq'>: '!=',
 <class '_ast.Lt'>: '<',
 <class '_ast.LtE'>: '<=',
 <class '_ast.Gt'>: '>',
 <class '_ast.GtE'>: '>=',
 <class '_ast.Is'>: 'is',
 <class '_ast.IsNot'>: 'is not',
...