diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index 0a16aa88..423e9743 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -150,7 +150,7 @@ def smart_file_resolve(filename: str, possible_paths: (str, List[str])) -> Path: possible_paths = [Path(path).resolve() for path in possible_paths if path is not None] for possible_path in possible_paths: resolved_path = (possible_path / filename).resolve() - if (resolved_path).exists(): + if resolved_path.exists(): return resolved_path else: raise Exception(f'{filename} was not found in any of the following locations: \n' + diff --git a/src/wireviz/wv_html.py b/src/wireviz/wv_html.py index ee8a4e02..37773f7f 100644 --- a/src/wireviz/wv_html.py +++ b/src/wireviz/wv_html.py @@ -12,9 +12,10 @@ def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], metadata: Metadata, options: Options): # load HTML template - if 'name' in metadata.get('template',{}): + templatename = metadata.get('template',{}).get('name') + if templatename: # if relative path to template was provided, check directory of YAML file first, fall back to built-in template directory - templatefile = smart_file_resolve(f'{metadata["template"]["name"]}.html', [Path(filename).parent, Path(__file__).parent / 'templates']) + templatefile = smart_file_resolve(f'{templatename}.html', [Path(filename).parent, Path(__file__).parent / 'templates']) else: # fall back to built-in simple template if no template was provided templatefile = Path(__file__).parent / 'templates/simple.html' @@ -49,8 +50,8 @@ def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], row_html = f'{row_html} \n' bom_contents.append(row_html) - bom_html = '\n' + bom_header_html + ''.join(bom_contents) + '
\n' - bom_html_reversed = '\n' + ''.join(list(reversed(bom_contents))) + bom_header_html + '
\n' + bom_html = '\n' + bom_header_html + ''.join(bom_contents) + '
\n' + bom_html_reversed = '\n' + ''.join(list(reversed(bom_contents))) + bom_header_html + '
\n' # prepare simple replacements replacements = {