Commit 67106b18 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Added cutoff argument to Node.dump() utility

parent e500b59b
...@@ -176,10 +176,13 @@ class Node(object): ...@@ -176,10 +176,13 @@ class Node(object):
self._end_pos = pos self._end_pos = pos
return pos return pos
def dump(self, level=0, filter_out=("pos",)): def dump(self, level=0, filter_out=("pos",), cutoff=100):
if cutoff == 0:
return "<...nesting level cutoff...>"
def dump_child(x, level): def dump_child(x, level):
if isinstance(x, Node): if isinstance(x, Node):
return x.dump(level) return x.dump(level, filter_out, cutoff-1)
elif isinstance(x, list): elif isinstance(x, list):
return "[%s]" % ", ".join([dump_child(item, level) for item in x]) return "[%s]" % ", ".join([dump_child(item, level) for item in x])
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment