From 11127726e4e447b8f6728a65ee72a1792e7afce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 26 Jul 2025 20:17:09 +0200 Subject: [PATCH] [scripts/pyprint] update maxlen selection - consider only values smaller than 'lmax' instead of taking the max of all lengths and trimming that - remove 'lmin' --- scripts/pyprint.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/pyprint.py b/scripts/pyprint.py index 3d10e026..b9d9c8d4 100644 --- a/scripts/pyprint.py +++ b/scripts/pyprint.py @@ -10,7 +10,7 @@ import re -def pyprint(obj, indent=0, lmin=9, lmax=16): +def pyprint(obj, indent=0, lmax=16): if isinstance(obj, str): if obj.startswith("lit:"): @@ -49,13 +49,7 @@ def pyprint(obj, indent=0, lmin=9, lmax=16): if len(obj) >= 2 or not indent: ws = " " * indent - - lkey = max(map(len, obj)) - if not indent: - if lkey < lmin: - lkey = lmin - elif lkey > lmax: - lkey = lmax + key_maxlen = max(kl for kl in map(len, obj) if kl <= lmax) lines = [] lines.append("{") @@ -65,7 +59,7 @@ def pyprint(obj, indent=0, lmin=9, lmax=16): else: lines.append( f'''{ws} "{key}"''' - f'''{' '*(lkey - len(key))}: ''' + f'''{' '*(key_maxlen - len(key))}: ''' f'''{pyprint(value, indent+4)},''' ) lines.append(f'''{ws}}}''')