mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-13 13:17:38 +02:00
Update renderers to work on populated treegrids.
This commit is contained in:
@@ -156,7 +156,10 @@ class QuickTextRenderer(CLIRenderer):
|
||||
accumulator.write("{}".format("\t".join(line)))
|
||||
return accumulator
|
||||
|
||||
grid.populate(visitor, outfd)
|
||||
if not grid.populated:
|
||||
grid.populate(visitor, outfd)
|
||||
else:
|
||||
grid.visit(node = None, function = visitor, initial_accumulator = outfd)
|
||||
|
||||
outfd.write("\n")
|
||||
|
||||
@@ -203,7 +206,10 @@ class CSVRenderer(CLIRenderer):
|
||||
accumulator.write("{}".format(",".join(line)))
|
||||
return accumulator
|
||||
|
||||
grid.populate(visitor, outfd)
|
||||
if not grid.populated:
|
||||
grid.populate(visitor, outfd)
|
||||
else:
|
||||
grid.visit(node = None, function = visitor, initial_accumulator = outfd)
|
||||
|
||||
outfd.write("\n")
|
||||
|
||||
@@ -251,7 +257,10 @@ class PrettyTextRenderer(CLIRenderer):
|
||||
return accumulator
|
||||
|
||||
final_output = [] # type: List[Tuple[int, Dict[Column, bytes]]]
|
||||
grid.populate(visitor, final_output)
|
||||
if not grid.populated:
|
||||
grid.populate(visitor, final_output)
|
||||
else:
|
||||
grid.visit(node = None, function = visitor, initial_accumulator = final_output)
|
||||
|
||||
# Always align the tree to the left
|
||||
format_string_list = ["{0:<" + str(max_column_widths[tree_indent_column]) + "s}"]
|
||||
|
||||
@@ -149,7 +149,7 @@ class TreeGrid(object, metaclass = ABCMeta):
|
||||
"""Method used to sanitize column names for TreeNodes."""
|
||||
|
||||
@abstractmethod
|
||||
def populate(self, func: VisitorSignature = None, initial_accumulator: Any = None) -> None:
|
||||
def populate(self, function: VisitorSignature = None, initial_accumulator: Any = None) -> None:
|
||||
"""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.
|
||||
|
||||
@@ -178,7 +178,7 @@ class TreeGrid(interfaces.renderers.TreeGrid):
|
||||
output += (letter if letter in 'abcdefghiljklmnopqrstuvwxyz_0123456789' else '_')
|
||||
return output
|
||||
|
||||
def populate(self, func: interfaces.renderers.VisitorSignature = None, initial_accumulator: Any = None) -> None:
|
||||
def populate(self, function: interfaces.renderers.VisitorSignature = None, initial_accumulator: Any = None) -> None:
|
||||
"""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.
|
||||
@@ -186,9 +186,9 @@ class TreeGrid(interfaces.renderers.TreeGrid):
|
||||
This is equivalent to a one-time visit.
|
||||
"""
|
||||
accumulator = initial_accumulator
|
||||
if func is None:
|
||||
if function is None:
|
||||
|
||||
def func(_x: interfaces.renderers.TreeNode, _y: Any) -> Any:
|
||||
def function(_x: interfaces.renderers.TreeNode, _y: Any) -> Any:
|
||||
return None
|
||||
|
||||
if not self.populated:
|
||||
@@ -198,8 +198,8 @@ class TreeGrid(interfaces.renderers.TreeGrid):
|
||||
parent = prev_nodes[parent_index - 1] if parent_index > 0 else None
|
||||
treenode = self._append(parent, item)
|
||||
prev_nodes = prev_nodes[0:parent_index] + [treenode]
|
||||
if func is not None:
|
||||
accumulator = func(treenode, accumulator)
|
||||
if function is not None:
|
||||
accumulator = function(treenode, accumulator)
|
||||
self._row_count += 1
|
||||
self._populated = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user