From 391d33ffb8c60aa2155aa30f6acc9e926564ac76 Mon Sep 17 00:00:00 2001 From: Daniel Osborne Date: Thu, 20 Nov 2025 15:22:55 -0800 Subject: [PATCH] Value substitution consumes spaces if available. Correction for commit 1b09c585345c58a2231a9b997c848eb114bab666 which now computes the number of characters needed between the label name and its value, and only consumes spaces up to that count. This prevents the substitution from consuming overlapping data and breaking the output, but allows preservation of column alignment. --- repgen/report/report.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/repgen/report/report.py b/repgen/report/report.py index 0657a2a..a69848b 100644 --- a/repgen/report/report.py +++ b/repgen/report/report.py @@ -104,7 +104,11 @@ def fill_report(self, output): if newval is None: newval = data_point.misstr # Replace every instance in the line *exactly* with the new value - tmp = tmp.replace(match.group(0), newval) + if self.compatibility: + # To ensure column alignment, grab as many spaces as required to fill in difference between the label name and value + tmp = re.sub(rf'{re.escape(match.group(0))} {{0,{max(0,len(newval) - len(match.group(0)))}}}', newval, tmp, flags=re.IGNORECASE) + else: + tmp = tmp.replace(match.group(0), newval) else: # pop the next value off the stack newval = data_point.pop() @@ -113,7 +117,8 @@ def fill_report(self, output): newval = data_point.misstr # Replace every instance in the line *exactly* with the new value if self.compatibility: - tmp = re.sub(re.escape(v), newval, tmp, flags=re.IGNORECASE) + # To ensure column alignment, grab as many spaces as required to fill in difference between the label name and value + tmp = re.sub(rf'{re.escape(v)} {{0,{max(0,len(newval) - len(v))}}}', newval, tmp, flags=re.IGNORECASE) else: tmp = tmp.replace(v, newval) if self.compatibility: