Skip to content

Commit

Permalink
Implement template-based HTML output
Browse files Browse the repository at this point in the history
  • Loading branch information
17o2 authored and laurierloi committed Jan 19, 2023
1 parent d44b649 commit a839a47
Show file tree
Hide file tree
Showing 4 changed files with 424 additions and 44 deletions.
284 changes: 284 additions & 0 deletions src/wireviz/templates/din-6771.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions src/wireviz/templates/simple.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/wireviz/wv_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

from typing import List
from pathlib import Path
import re

awg_equiv_table = {
Expand Down Expand Up @@ -134,3 +135,21 @@ def aspect_ratio(image_src):
except Exception as error:
print(f'aspect_ratio(): {type(error).__name__}: {error}')
return 1 # Assume 1:1 when unable to read actual image size


def smart_file_resolve(filename, possible_paths):
filename = Path(filename)
if filename.is_absolute():
if filename.exists():
return filename
else:
raise Exception(f'{filename} does not exist.')
else: # search all possible paths in decreasing order of precedence
possible_paths = [Path(path).resolve() for path in possible_paths]
for possible_path in possible_paths:
resolved_path = (possible_path / filename).resolve()
if (resolved_path).exists():
return resolved_path
else:
raise Exception(f'{filename} was not found in any of the following locations: \n' +
'\n'.join([str(x) for x in possible_paths]))
Loading

0 comments on commit a839a47

Please sign in to comment.