diff --git a/parse_excel.py b/parse_excel.py index ac6fbcb..a0579b5 100644 --- a/parse_excel.py +++ b/parse_excel.py @@ -9,7 +9,7 @@ parser = ArgumentParser( prog="parse Excel", - usage="python parse_excel.py --file ", + usage="python parse_excel.py --file path/to/excel/file", description="An Excel file that contains subnets", epilog="Enjoy the program! :)", allow_abbrev=True, @@ -23,12 +23,14 @@ action="store", type=str, required=True, - help="the path to an Excel file", + help="Path to an Excel file", ) args = parser.parse_args() try: - svi_generator(excel_file=args.file) + f = svi_generator(excel_file=args.file) except (FileNotFoundError, PermissionError) as e: raise SystemExit(print(f"[red]{e}")) from e +else: + print(f"\n[green]Created {f.name} in cwd", end="\n\n") diff --git a/svi_generator.py b/svi_generator.py index ed07ad8..34f1072 100644 --- a/svi_generator.py +++ b/svi_generator.py @@ -52,8 +52,8 @@ def svi_generator(excel_file: str) -> None: svi_cfg = template.render(vlans=vlans) # Export the template result to a text file - cfg_fname = f'{excel_file.replace(".xlsx", "")}_svi.txt' - with open(file=cfg_fname, mode="wt", encoding="utf-8") as cfg_file: - cfg_file.write(svi_cfg) + cfg_fname = f'{excel_file.replace(".xlsx", "")}_SVI-template.txt' + with open(file=cfg_fname, mode="wt+", encoding="utf-8") as f: + f.write(svi_cfg) - print(f"\n[green]Created {cfg_fname}", end="\n\n") + return f