diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index c0c8190f..49576529 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -716,8 +716,7 @@ def output( # BOM output bomlist = bom_list(self.bom()) if "tsv" in fmt: - with open_file_write(f"{filename}.bom.tsv") as file: - file.write(tuplelist2tsv(bomlist)) + open_file_write(f"{filename}.bom.tsv").write(tuplelist2tsv(bomlist)) if "csv" in fmt: # TODO: implement CSV output (preferrably using CSV library) print("CSV output is not yet supported") diff --git a/src/wireviz/wv_cli.py b/src/wireviz/wv_cli.py index 83ff164b..73150720 100644 --- a/src/wireviz/wv_cli.py +++ b/src/wireviz/wv_cli.py @@ -107,8 +107,7 @@ def wireviz(file, format, prepend, output_dir, output_name, version): raise Exception(f"File does not exist:\n{prepend_file}") print("Prepend file:", prepend_file) - with open_file_read(prepend_file) as file_handle: - prepend_input += file_handle.read() + "\n" + prepend_input += open_file_read(prepend_file).read() + "\n" else: prepend_input = "" @@ -127,8 +126,7 @@ def wireviz(file, format, prepend, output_dir, output_name, version): "Output file: ", f"{Path(_output_dir / _output_name)}.{output_formats_str}" ) - with open_file_read(file) as file_handle: - yaml_input = file_handle.read() + yaml_input = open_file_read(file).read() file_dir = file.parent yaml_input = prepend_input + yaml_input diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index 6b85ef71..b30bdeeb 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -34,8 +34,7 @@ def generate_html_output( # fall back to built-in simple template if no template was provided templatefile = Path(__file__).parent / "templates/simple.html" - with open_file_read(templatefile) as file: - html = file.read() + html = open_file_read(templatefile).read() # embed SVG diagram with open_file_read(f"{filename}.svg") as file: @@ -117,5 +116,4 @@ def generate_html_output( pattern = re.compile("|".join(replacements_escaped)) html = pattern.sub(lambda match: replacements[match.group(0)], html) - with open_file_write(f"{filename}.html") as file: - file.write(html) + open_file_write(f"{filename}.html").write(html)