diff options
| author | bd <bdunahu@operationnull.com> | 2025-11-30 22:22:31 -0500 |
|---|---|---|
| committer | bd <bdunahu@operationnull.com> | 2025-11-30 22:22:31 -0500 |
| commit | d85ccbe6cf340f758a971af855c809457607cd7a (patch) | |
| tree | 33b49a9c6c356bf6c514a1778b51166af0e713b2 /nemesis/nemesis.py | |
| parent | 32da6c437587b6ad12050cfb53e938c78de092e4 (diff) | |
nemesis: add validate_html.
nemesis/nemesis.py: add validate_html
- argparse: ensure passed filename is an HTML.
Diffstat (limited to 'nemesis/nemesis.py')
| -rwxr-xr-x | nemesis/nemesis.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/nemesis/nemesis.py b/nemesis/nemesis.py index e7c5e7e..c1a6fb2 100755 --- a/nemesis/nemesis.py +++ b/nemesis/nemesis.py @@ -340,6 +340,11 @@ def validate_dir(path_str: str) -> Path: raise ValueError(f"Can't profile a non-dir: {p}") return p +def validate_html(filename: str) -> str: + if not filename.lower().endswith('.html'): + raise argparse.ArgumentTypeError(f"Did not name an HTML file: '{filename}'") + return filename + if __name__ == "__main__": # parses CLI arguments and facilitates profiler runtime. parser = argparse.ArgumentParser( @@ -358,20 +363,20 @@ if __name__ == "__main__": type=float, default=3) parser.add_argument('-f', '--filename', - help='The filename to write results to.', + help='The filename to write results to. Must name an HTML file.', metavar='', - type=str, + type=validate_html, default="results.html") - # parser.add_argument('--include-paths', - # help='Specify the path(s) containing files to profile. If a file is in this path, it is a candidate for optimization.', - # nargs="+", - # type=validate_dir, - # required=True) - # parser.add_argument('--exclude-paths', - # help='Specify the path(s) containing files to exclude profile. Takes priority over --include-paths.', - # nargs="*", - # type=validate_dir, - # required=False) + parser.add_argument('--include-paths', + help='Specify the path(s) containing files to profile. If a file is in this path, it is a candidate for optimization.', + nargs="+", + type=validate_dir, + required=True) + parser.add_argument('--exclude-paths', + help='Specify the path(s) containing files to exclude profile. Takes priority over --include-paths.', + nargs="*", + type=validate_dir, + required=False) parser.add_argument('prog', type=str, nargs='*', |
