Revert the generator changes, the visiting function should be used instead.

This commit is contained in:
Mike Auty
2017-08-02 10:40:16 +01:00
parent d8c53b63bf
commit ab8d76eeef
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -137,7 +137,8 @@ class TreeGrid(interfaces.renderers.TreeGrid):
return output
def populate(self, func = None, initial_accumulator = None):
"""Generator that returns the next available Node
"""Populates the tree by consuming the TreeGrid's construction generator
Func is called on every node, so can be used to create output on demand
This is equivalent to a one-time visit.
"""
@@ -155,7 +156,6 @@ class TreeGrid(interfaces.renderers.TreeGrid):
prev_nodes = prev_nodes[0: parent_index] + [treenode]
accumulator = func(treenode, accumulator)
self._row_count += 1
yield (level, item)
self._populated = True
@property
@@ -240,7 +240,7 @@ class TreeGrid(interfaces.renderers.TreeGrid):
for every node we descend further down
"""
if not self.populated:
list(self.populate())
self.populate()
# Find_nodes is path dependent, whereas _visit is not
# So in case the function modifies the node's path, find the nodes first
+1 -1
View File
@@ -53,4 +53,4 @@ class QuickTextRenderer(interfaces.renderers.Renderer):
accumulator.write("\n")
return accumulator
list(grid.populate(visitor, outfd))
grid.populate(visitor, outfd)