[autotest] Make `atest stable_version list` readable again.
The output of the `atest stable_version list` command used
fixed-width columns in its output, and those widths were much to
small for typical output. The result was that the output was
not tabular, and largely not readable.
This changes the command to use dynamically selected column
widths, so that the output will always be tabular.
BUG=None
TEST=run the command, see reasonable output
Change-Id: Id1ee3a74400caf9b3258d7cba2b91d9cae4fe895
Reviewed-on: https://chromium-review.googlesource.com/314289
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
diff --git a/cli/stable_version.py b/cli/stable_version.py
index 11b5726..72b517e 100644
--- a/cli/stable_version.py
+++ b/cli/stable_version.py
@@ -90,13 +90,16 @@
@param results: A dictionary of board:version.
"""
- format = '%-12s| %-20s'
- print '='*30
+ board_columns = max([len(s) for s in results.keys()])
+ version_columns = max([len(s) for s in results.values()])
+ total_columns = board_columns + version_columns + 3
+ format = '%%-%ds | %%s' % board_columns
+ print '=' * total_columns
print format % ('board', 'version')
- print '-'*30
+ print '-' * total_columns
for board,version in results.iteritems():
print format % (board, version)
- print '='*30
+ print '=' * total_columns
class stable_version_modify(stable_version):