From 6f56fcda99bc57e8a7a57e1d809df5a52851a5db Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Mon, 29 Mar 2021 14:14:40 +0200 Subject: [PATCH] Add small fixes --- src/wireviz/wv_html.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index 77da9871..a140b40c 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -20,11 +20,11 @@ def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], # fall back to built-in simple template if no template was provided templatefile = Path(__file__).parent / 'templates/simple.html' - with open(templatefile, 'r') as file: + with open_file_read(templatefile) as file: html = file.read() # embed SVG diagram - with open(f'{filename}.svg') as file: + with open_file_read(f'{filename}.svg') as file: svgdata = file.read() svgdata = re.sub( '^<[?]xml [^?>]*[?]>[^<]*]*>', @@ -74,7 +74,7 @@ def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], # fill out other generic metadata for item, contents in metadata.items(): if isinstance(contents, (str, int, float)): - html = html.replace(f'', html_line_breaks(contents)) + html = html.replace(f'', html_line_breaks(str(contents))) elif isinstance(contents, Dict): # useful for authors, revisions for index, (category, entry) in enumerate(contents.items()): if isinstance(entry, Dict): @@ -83,5 +83,5 @@ def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], html = html.replace(f'', html_line_breaks(str(entry_value))) - with open(f'{filename}.html','w') as file: + with open_file_write(f'{filename}.html') as file: file.write(html)