Commit 4d12bec3 authored by Stefan Behnel's avatar Stefan Behnel

allow restricting the output to certain interesting lines in PrintTree()

parent 45b7c136
......@@ -709,12 +709,17 @@ class PrintTree(TreeVisitor):
"""Prints a representation of the tree to standard output.
Subclass and override repr_of to provide more information
about nodes. """
def __init__(self):
def __init__(self, start=None, end=None):
TreeVisitor.__init__(self)
self._indent = ""
if start is not None or end is not None:
self._line_range = (start or 0, end or 2**30)
else:
self._line_range = None
def indent(self):
self._indent += " "
def unindent(self):
self._indent = self._indent[:-2]
......@@ -728,6 +733,8 @@ class PrintTree(TreeVisitor):
# under the parent-node, not displaying the list itself in
# the hierarchy.
def visit_Node(self, node):
line = node.pos[1]
if self._line_range is None or self._line_range[0] <= line <= self._line_range[1]:
if len(self.access_path) == 0:
name = "(root)"
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