Skip to content

Commit e14ce0e

Browse files
committed
tweak in column display
1 parent 0513a03 commit e14ce0e

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

script/diff_schemas.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,16 @@ def _print_table(title, rows, col_defs, indent=" ", concise=False):
518518
print(pad + " ".join(seps))
519519
prefix_cols = min(4, len(col_defs) - 1) # never blank the last (value) column
520520
for row_idx, row in enumerate(rows):
521+
# Concise: blank all prefix columns only when every one matches the previous row.
522+
# If any prefix value differs, show all prefix values.
523+
hide_prefix = (
524+
concise
525+
and row_idx > 0
526+
and all(str(row[i]) == str(rows[row_idx - 1][i]) for i in range(prefix_cols))
527+
)
521528
cells = []
522529
for i, (v, (h, w)) in enumerate(zip(row, col_defs)):
523-
if concise and row_idx > 0 and i < prefix_cols:
524-
# Blank if identical to the original (pre-display) previous row
525-
s = "" if str(v) == str(rows[row_idx - 1][i]) else str(v) if v is not None else ""
526-
else:
527-
s = str(v) if v is not None else ""
530+
s = "" if (hide_prefix and i < prefix_cols) else (str(v) if v is not None else "")
528531
if i < len(col_defs) - 1:
529532
cells.append((s[:w-3] + "..." if len(s) > w else s).ljust(w))
530533
else:

0 commit comments

Comments
 (0)