diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-09-17 18:02:21 +0000 |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-09-17 18:02:21 +0000 |
commit | 818a42c4784a9421b77c2cfd2772b1f7097aa25b (patch) | |
tree | d3628856f68f7df2a2b6a2b228e5b06380f8cdbd /Tools/compiler | |
parent | 62be97c05d4ff0cc22b03e9b0ba6e557fc6f99c2 (diff) | |
download | cpython-818a42c4784a9421b77c2cfd2772b1f7097aa25b.tar.gz |
Add utility to set filename attribute on all nodes
Diffstat (limited to 'Tools/compiler')
-rw-r--r-- | Tools/compiler/compiler/misc.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Tools/compiler/compiler/misc.py b/Tools/compiler/compiler/misc.py index 9cbd73ff23..b4bbe78050 100644 --- a/Tools/compiler/compiler/misc.py +++ b/Tools/compiler/compiler/misc.py @@ -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()) + |