diff --git a/scripts/csv.py b/scripts/csv.py index a0d92e32..ff98b6dd 100755 --- a/scripts/csv.py +++ b/scripts/csv.py @@ -1281,7 +1281,7 @@ def punescape(s, attrs=None): '|' '%u....' '|' '%U........' '|' '%\((?P[^)]*)\)' - '(?P[+\- #0-9\.]*[scdboxXfFeEgG])') + '(?P[+\- #0-9\.]*[sdboxXfFeEgG])') def unescape(m): if m.group()[1] == '%': return '%' elif m.group()[1] == 'n': return '\n' @@ -1310,6 +1310,23 @@ def punescape(s, attrs=None): else: assert False return re.sub(pattern, unescape, s) +def punescape_help(): + print('mods:') + print(' %-21s %s' % ('%%', 'A literal % character')) + print(' %-21s %s' % ('%n', 'A newline')) + print(' %-21s %s' % ( + '%xaa', 'A character with the hex value aa')) + print(' %-21s %s' % ( + '%uaaaa', 'A character with the hex value aaaa')) + print(' %-21s %s' % ( + '%Uaaaaaaaa', 'A character with the hex value aaaaaaaa')) + print(' %-21s %s' % ( + '%(field)s', 'An existing field formatted as a string')) + print(' %-21s %s' % ( + '%(field)[dboxX]', 'An existing field formatted as an integer')) + print(' %-21s %s' % ( + '%(field)[fFeEgG]', 'An existing field formatted as a float')) + def openio(path, mode='r', buffering=-1): # allow '-' for stdin/stdout @@ -2122,6 +2139,9 @@ def main(csv_paths, *, import builtins enumerate_, enumerate = enumerate, builtins.enumerate + # show mod help text? + if args.get('help_mods'): + return punescape_help() # show expr help text? if args.get('help_exprs'): return RExpr.help() @@ -2331,6 +2351,10 @@ if __name__ == "__main__": 'csv_paths', nargs='*', help="Input *.csv files.") + parser.add_argument( + '--help-mods', + action='store_true', + help="Show what %% modifiers are available.") parser.add_argument( '--help-exprs', action='store_true', diff --git a/scripts/plot.py b/scripts/plot.py index 1c3bf4e9..ef65fd80 100755 --- a/scripts/plot.py +++ b/scripts/plot.py @@ -480,7 +480,7 @@ def punescape(s, attrs=None): '|' '%u....' '|' '%U........' '|' '%\((?P[^)]*)\)' - '(?P[+\- #0-9\.]*[scdboxXfFeEgG])') + '(?P[+\- #0-9\.]*[sdboxXfFeEgG])') def unescape(m): if m.group()[1] == '%': return '%' elif m.group()[1] == 'n': return '\n' diff --git a/scripts/plotmpl.py b/scripts/plotmpl.py index 2b37b16e..dbf47453 100755 --- a/scripts/plotmpl.py +++ b/scripts/plotmpl.py @@ -404,7 +404,7 @@ def punescape(s, attrs=None): '|' '%u....' '|' '%U........' '|' '%\((?P[^)]*)\)' - '(?P[+\- #0-9\.]*[scdboxXfFeEgG])') + '(?P[+\- #0-9\.]*[sdboxXfFeEgG])') def unescape(m): if m.group()[1] == '%': return '%' elif m.group()[1] == 'n': return '\n' diff --git a/scripts/treemap.py b/scripts/treemap.py index 94a30393..4de63c4a 100755 --- a/scripts/treemap.py +++ b/scripts/treemap.py @@ -264,7 +264,7 @@ def punescape(s, attrs=None): '|' '%u....' '|' '%U........' '|' '%\((?P[^)]*)\)' - '(?P[+\- #0-9\.]*[scdboxXfFeEgG])') + '(?P[+\- #0-9\.]*[sdboxXfFeEgG])') def unescape(m): if m.group()[1] == '%': return '%' elif m.group()[1] == 'n': return '\n' diff --git a/scripts/treemapd3.py b/scripts/treemapd3.py index 11c2b26c..73e3c946 100755 --- a/scripts/treemapd3.py +++ b/scripts/treemapd3.py @@ -280,7 +280,7 @@ def punescape(s, attrs=None): '|' '%u....' '|' '%U........' '|' '%\((?P[^)]*)\)' - '(?P[+\- #0-9\.]*[scdboxXfFeEgG])') + '(?P[+\- #0-9\.]*[sdboxXfFeEgG])') def unescape(m): if m.group()[1] == '%': return '%' elif m.group()[1] == 'n': return '\n'