Exemplo n.º 1
0
 def visit_assname(self, node, parent, node_name=None):
     '''visit a node and return a AssName node'''
     newnode = new.AssName()
     _set_infos(node, newnode, parent)
     newnode.name = node_name
     self._save_assignment(newnode)
     return newnode
Exemplo n.º 2
0
 def visit_assname(self, node, parent):
     """visit an AssName node by returning a fresh instance of it"""
     delnode = self._check_del_node(node, parent, [node])
     if delnode:
         return delnode
     elif self.asscontext == "Del":
         return self.visit_delname(node, parent)
     assert self.asscontext in ("Ass", "Aug")
     newnode = new.AssName()
     self._set_infos(node, newnode, parent)
     newnode.name = node.name
     self._save_assignment(newnode)
     return newnode
Exemplo n.º 3
0
 def _nodify_args(self, parent, values):
     """transform arguments and tuples or lists of arguments into astng nodes"""
     res = []
     for arg in values:
         if isinstance(arg, (tuple, list)):
             n = new.Tuple()
             self._set_infos(parent, n, parent)
             n.elts = self._nodify_args(n, arg)
         else:
             assert isinstance(arg, basestring)
             n = new.AssName()
             self._set_infos(parent, n, parent)
             n.name = arg
             self._save_assignment(n, n.name)
         res.append(n)
     return res
Exemplo n.º 4
0
 def visit_name(self, node, parent):
     """visit a Name node by returning a fresh instance of it"""
     if node.id in CONST_NAME_TRANSFORMS:
         newnode = new.Const(CONST_NAME_TRANSFORMS[node.id])
         self._set_infos(node, newnode, parent)
         return newnode
     if self.asscontext == "Del":
         newnode = new.DelName()
     elif self.asscontext is not None: # Ass
         assert self.asscontext == "Ass"
         newnode = new.AssName()
     else:
         newnode = new.Name()
     _lineno_parent(node, newnode, parent)
     newnode.name = node.id
     # XXX REMOVE me :
     if self.asscontext in ('Del', 'Ass'): # 'Aug' ??
         self._save_assignment(newnode)
     newnode.set_line_info(newnode.last_child())
     return newnode