summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-12-28 11:26:31 -0800
committerGitHub <noreply@github.com>2019-12-28 11:26:31 -0800
commit2dafeaf81995614374a3da5c6b3fb3cf5d96771b (patch)
tree26af27976e6b746db9425a41d0abdc5639610bc8
parent855f9afa6e8d7afba020dc5c1dc8fabfc84ba2d4 (diff)
downloadspack-2dafeaf81995614374a3da5c6b3fb3cf5d96771b.tar.gz
spack-2dafeaf81995614374a3da5c6b3fb3cf5d96771b.tar.bz2
spack-2dafeaf81995614374a3da5c6b3fb3cf5d96771b.tar.xz
spack-2dafeaf81995614374a3da5c6b3fb3cf5d96771b.zip
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()`
-rw-r--r--lib/spack/llnl/util/tty/colify.py17
1 files 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)