mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
Add utility to set filename attribute on all nodes
This commit is contained in:
parent
b329b7134c
commit
09392b77a4
2 changed files with 18 additions and 0 deletions
|
@ -64,3 +64,12 @@ def mangle(name, klass):
|
|||
klass = klass[:MANGLE_LEN-tlen]
|
||||
|
||||
return "_%s%s" % (klass, name)
|
||||
|
||||
def set_filename(filename, tree):
|
||||
"""Set the filename attribute to filename on every node in tree"""
|
||||
worklist = [tree]
|
||||
while worklist:
|
||||
node = worklist.pop(0)
|
||||
node.filename = filename
|
||||
worklist.extend(node.getChildNodes())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue