From 09392b77a4d8be766e394177a466d51c2a64480f Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Mon, 17 Sep 2001 18:02:21 +0000 Subject: Add utility to set filename attribute on all nodes --- Lib/compiler/misc.py | 9 +++++++++ Tools/compiler/compiler/misc.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py index 9cbd73f..b4bbe78 100644 --- a/Lib/compiler/misc.py +++ b/Lib/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()) + diff --git a/Tools/compiler/compiler/misc.py b/Tools/compiler/compiler/misc.py index 9cbd73f..b4bbe78 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()) + -- cgit v0.12