示例#1
0
 def accept(self, visitor):
     klass = self.__class__.__name__
     func = getattr(visitor, "visit_" + REDIRECT.get(klass, klass).lower())
     return func(self)
示例#2
0
Slice._astng_fields = ('lower', 'upper', 'step')
Subscript._astng_fields = ('value', 'slice')
TryExcept._astng_fields = ('body', 'handlers', 'orelse',)
TryFinally._astng_fields = ('body', 'finalbody',)
Tuple._astng_fields = ('elts',)  # ctx
With._astng_fields = ('expr', 'vars', 'body')
While._astng_fields = ('test', 'body', 'orelse',)
Yield._astng_fields = ('value',)



# extend all classes
# TODO : use __bases__ instead of extend_class

LOCALS_NODES = (Class, Function, GenExpr, Lambda, Module)

for cls in ALL_NODES:
    if cls in LOCALS_NODES:
        cls_module = scoped_nodes
    else:
        cls_module = node_classes
    ng_class = getattr(cls_module, REDIRECT.get(cls.__name__, cls.__name__) + "NG")
    addons = list((ng_class,) + ng_class.__bases__)
    addons.reverse()
    extend_class(cls,  addons)
    # cls.__bases__ += (ng_class,) + ng_class.__bases__

# _scope_lookup only available with LookupMixIn extention
GenExpr.scope_lookup = GenExpr._scope_lookup