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:
parent
a3b1921793
commit
06d351f054
@ -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'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user