From 2dafeaf81995614374a3da5c6b3fb3cf5d96771b Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sat, 28 Dec 2019 11:26:31 -0800 Subject: 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()` --- lib/spack/llnl/util/tty/colify.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/spack/llnl/util/tty/colify.py b/lib/spack/llnl/util/tty/colify.py index d5e0aa8def..6a4fc3b0e5 100644 --- a/lib/spack/llnl/util/tty/colify.py +++ b/lib/spack/llnl/util/tty/colify.py @@ -199,10 +199,16 @@ def colify(elts, **options): def colify_table(table, **options): """Version of ``colify()`` for data expressed in rows, (list of lists). - Same as regular colify but takes a list of lists, where each - sub-list must be the same length, and each is interpreted as a - row in a table. Regular colify displays a sequential list of - values in columns. + Same as regular colify but: + + 1. This takes a list of lists, where each sub-list must be the + 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: raise TypeError("Can't call colify_table on NoneType") @@ -220,6 +226,9 @@ def colify_table(table, **options): raise ValueError("Cannot override columsn in colify_table.") options['cols'] = columns + # don't reduce to 1 column for non-tty + options['tty'] = True + colify(transpose(), **options) -- cgit v1.2.3-70-g09d2