bugfix: colify_table should not revert to 1 column for non-tty (#14307)
Commands like `spack blame` were printig poorly when redirected to files, as colify reverts to a single column when redirected. This works for list data but not tables. - [x] Force a table by always passing `tty=True` from `colify_table()`
This commit is contained in:
parent
855f9afa6e
commit
2dafeaf819
@ -199,10 +199,16 @@ def colify(elts, **options):
|
|||||||
def colify_table(table, **options):
|
def colify_table(table, **options):
|
||||||
"""Version of ``colify()`` for data expressed in rows, (list of lists).
|
"""Version of ``colify()`` for data expressed in rows, (list of lists).
|
||||||
|
|
||||||
Same as regular colify but takes a list of lists, where each
|
Same as regular colify but:
|
||||||
sub-list must be the same length, and each is interpreted as a
|
|
||||||
row in a table. Regular colify displays a sequential list of
|
1. This takes a list of lists, where each sub-list must be the
|
||||||
values in columns.
|
same length, and each is interpreted as a row in a table.
|
||||||
|
Regular colify displays a sequential list of values in columns.
|
||||||
|
|
||||||
|
2. Regular colify will always print with 1 column when the output
|
||||||
|
is not a tty. This will always print with same dimensions of
|
||||||
|
the table argument.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if table is None:
|
if table is None:
|
||||||
raise TypeError("Can't call colify_table on NoneType")
|
raise TypeError("Can't call colify_table on NoneType")
|
||||||
@ -220,6 +226,9 @@ def transpose():
|
|||||||
raise ValueError("Cannot override columsn in colify_table.")
|
raise ValueError("Cannot override columsn in colify_table.")
|
||||||
options['cols'] = columns
|
options['cols'] = columns
|
||||||
|
|
||||||
|
# don't reduce to 1 column for non-tty
|
||||||
|
options['tty'] = True
|
||||||
|
|
||||||
colify(transpose(), **options)
|
colify(transpose(), **options)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user