1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-21 01:59:13 +00:00

utils/misc: fix write_table column widths

Consider headers when calculating column widths. This will ensure proper
alignment in cases where the column header is wider than any of the
column values.
This commit is contained in:
Sergei Trofimov 2018-06-27 15:38:42 +01:00 committed by Marc Bonnici
parent a3b1921793
commit 06d351f054

View File

@ -110,6 +110,8 @@ def write_table(rows, wfh, align='>', headers=None): # pylint: disable=R0914
cols = list(zip(*rows))
col_widths = [max(list(map(len, c))) for c in cols]
if headers:
col_widths = [max([c, len(h)]) for c, h in zip(col_widths, headers)]
row_format = ' '.join(['{:%s%s}' % (align[i], w) for i, w in enumerate(col_widths)])
row_format += '\n'