Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Tes3awy committed Sep 2, 2024
1 parent 3fd3d62 commit 7ecee1c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/vetr_summarizer/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from pathlib import Path

from vetr_summarizer.html_generator import generate_html
Expand All @@ -10,10 +10,12 @@
def main():
parser = ArgumentParser(
prog="vetr-summarizer",
description="Process and summarize aci-vetr-data JSON files into HTML reports.",
formatter_class=ArgumentDefaultsHelpFormatter,
description="Process and summarize aci-vetr-data JSON files into pretty HTML reports.",
epilog="Thanks for using %(prog)s! :)",
add_help=True,
allow_abbrev=True,
exit_on_error=True,
conflict_handler="error",
)
parser.add_argument(
Expand All @@ -22,16 +24,24 @@ def main():
help="A path to the directory containing the JSON files.",
)
parser.add_argument(
"-f", "--format", choices=["html"], default="html", help="Output format (html)."
"-f",
"--format",
choices=["html"],
required=False,
default="html",
help="Output format",
)
parser.add_argument(
"-x",
"--exclude-file",
type=Path,
required=False,
default=Path(__file__).parent / "config/excluded_keys",
help="File containing keys to exclude from the summary report.",
)
parser.add_argument("-v", "--version", action="version", version=__version__)
parser.add_argument(
"-v", "--version", action="version", version=f"%(prog)s version {__version__}"
)
args = parser.parse_args()

output_file = generate_html(args.directory, args.exclude_file)
Expand Down
6 changes: 6 additions & 0 deletions src/vetr_summarizer/html_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def load_excluded_keys(file_path: Path) -> set:
print(f"WARNING: {file_path} does not exist! No keys will be excluded.")
return set()

if file_path.exists() and not file_path.read_text().splitlines():
print(
f"WARNING: {file_path} does exists but without keys! No keys will be excluded."
)
return set()

return {
key.strip()
for key in Path(file_path).read_text().splitlines()
Expand Down

0 comments on commit 7ecee1c

Please sign in to comment.