Try to slightly clean up table rendering in the CLI.

This commit is contained in:
Mike Auty
2018-12-30 17:17:15 +00:00
parent afdd8b657e
commit bb872863f9
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ class PrintedProgress(object):
message = "\rProgress: {0: 7.2f}\t\t{1:}".format(round(progress, 2), description or '')
message_len = len(message)
self._max_message_len = max([self._max_message_len, message_len])
print(message, end = ' ' * (self._max_message_len - message_len))
print(message, end = (' ' * (self._max_message_len - message_len)) + '\r')
class MuteProgress(PrintedProgress):
+6 -3
View File
@@ -135,18 +135,21 @@ class QuickTextRenderer(interfaces.renderers.Renderer):
# TODO: Improve text output
outfd = sys.stdout
line = []
for column in grid.columns:
# Ignore the type because namedtuples don't realize they have accessible attributes
outfd.write("\t{}".format(column.name)) # type: ignore
outfd.write("\n")
line.append("{}".format(column.name))
outfd.write("\n{}\n".format("\t".join(line)))
def visitor(node, accumulator):
accumulator.write("\n")
# Nodes always have a path value, giving them a path_depth of at least 1, we use max just in case
accumulator.write("*" * max(0, node.path_depth - 1))
line = []
for column in grid.columns:
renderer = self.type_renderers.get(column.type, self.type_renderers['default'])
accumulator.write("\t" + renderer(node.values[column.index]))
line.append(renderer(node.values[column.index]))
accumulator.write("{}".format("\t".join(line)))
return accumulator
grid.populate(visitor, outfd)