diff options
author | Sergei Trofimov <sergei.trofimov@arm.com> | 2018-06-27 15:38:42 +0100 |
---|---|---|
committer | Marc Bonnici <marc.bonnici@arm.com> | 2018-06-28 10:32:36 +0100 |
commit | 06d351f054d5fc5a55027629d18a01050f0d1ec0 (patch) | |
tree | 2e094e83834409be4bd2212eb8a37a9f645bde0c /wa/utils | |
parent | a3b1921793b94dab1c8b78d434aced158a131327 (diff) |
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.
Diffstat (limited to 'wa/utils')
-rw-r--r-- | wa/utils/misc.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/wa/utils/misc.py b/wa/utils/misc.py index bb9ab546..2090c24a 100644 --- a/wa/utils/misc.py +++ b/wa/utils/misc.py @@ -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' |