Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: kvid <kvid@users.noreply.github.com>
  • Loading branch information
formatc1702 and kvid committed Oct 15, 2021
1 parent 33cebee commit 2d6c7b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/wireviz/wv_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' +
Expand Down
9 changes: 5 additions & 4 deletions src/wireviz/wv_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -49,8 +50,8 @@ def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]],
row_html = f'{row_html} </tr>\n'
bom_contents.append(row_html)

bom_html = '<table>\n' + bom_header_html + ''.join(bom_contents) + '</table>\n'
bom_html_reversed = '<table>\n' + ''.join(list(reversed(bom_contents))) + bom_header_html + '</table>\n'
bom_html = '<table class="bom">\n' + bom_header_html + ''.join(bom_contents) + '</table>\n'
bom_html_reversed = '<table class="bom">\n' + ''.join(list(reversed(bom_contents))) + bom_header_html + '</table>\n'

# prepare simple replacements
replacements = {
Expand Down

0 comments on commit 2d6c7b4

Please sign in to comment.