From 35e89d4fdf7d2ba8e20bcd73901d9f5b59bb86a4 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Thu, 7 Oct 2021 23:38:06 +0200 Subject: [PATCH] Simplify `main()` --- src/wireviz/wireviz.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wireviz/wireviz.py b/src/wireviz/wireviz.py index c666188..ecdb27f 100755 --- a/src/wireviz/wireviz.py +++ b/src/wireviz/wireviz.py @@ -312,11 +312,13 @@ def main(): args = parse_cmdline() - if not Path(args.input_file).exists(): - print(f'Error: input file {args.input_file} inaccessible or does not exist, check path') + file_in = Path(args.input_file) + + if not file_in.exists(): + print(f'Error: input file {file_in} inaccessible or does not exist, check path') sys.exit(1) - with open_file_read(args.input_file) as fh: + with open_file_read(file_in) as fh: yaml_input = fh.read() if args.prepend_file: @@ -328,8 +330,7 @@ def main(): yaml_input = prepend + yaml_input if not args.output_file: - file_out = Path(args.input_file) - file_out = file_out.parent / file_out.stem # extension will be added by graphviz output function + file_out = file_in.parent / file_in.stem # extension will be added by graphviz output function else: file_out = Path(args.output_file) file_out = file_out.resolve()