Ejemplo n.º 1
0
def replace(node, stringMap, check_set=set(), verbose=False):
    mapper = NameMapper(check_set)
    for cstring,value in stringMap.items():
        var_name = mapper.mapper(cstring)
        value[0] = var_name  # memoize var_name in stringMap
        for node in value[1]:
            repl_ident = treeutil.compileString(var_name)
            repl_ident.set("line", node.get("line"))
            repl_ident.set("column", node.get("column"))
            node.parent.replaceChild(node, repl_ident)
Ejemplo n.º 2
0
def replace(node, stringMap, check_set=set(), verbose=False):
    mapper = NameMapper(check_set)
    for cstring, value in stringMap.items():
        var_name = mapper.mapper(cstring)
        value[0] = var_name  # memoize var_name in stringMap
        for node in value[1]:
            repl_ident = treeutil.compileString(var_name)
            repl_ident.set("line", node.get("line"))
            repl_ident.set("column", node.get("column"))
            node.parent.replaceChild(node, repl_ident)
Ejemplo n.º 3
0
 def __init__(self, template='%s', check_set=None):
     types.DictType.__init__(self)
     NameMapper.__init__(self, check_set)
     self.template = template
Ejemplo n.º 4
0
 def __init__(self, template='%s', check_set=None):
     types.DictType.__init__(self)
     NameMapper.__init__(self, check_set)
     self.template = template