Fix package_data for gvpr and empty BOM crash
Some checks are pending
Create Examples / build (ubuntu-latest, 3.9) (push) Waiting to run
Create Examples / build (ubuntu-22.04, 3.7) (push) Waiting to run
Create Examples / build (ubuntu-22.04, 3.8) (push) Waiting to run
Create Examples / build (ubuntu-latest, 3.10) (push) Waiting to run
Create Examples / build (ubuntu-latest, 3.11) (push) Waiting to run
Create Examples / build (ubuntu-latest, 3.12) (push) Waiting to run

- Include *.gvpr files in package_data so wv_gvpr.gvpr ships
  in the wheel distribution (reported by web-ui integration agent)
- Guard generate_html_output() against empty BOM list to prevent
  IndexError when YAML has no connectors/cables
This commit is contained in:
Ryan Malloy 2026-02-13 01:00:07 -07:00
parent 31db67921a
commit 5e2634e7b8
2 changed files with 29 additions and 25 deletions

View File

@ -29,7 +29,7 @@ setup(
keywords="cable connector hardware harness wiring wiring-diagram wiring-harness",
url=APP_URL,
package_dir={"": "src"},
package_data={CMD_NAME: ["templates/*.html"]},
package_data={CMD_NAME: ["templates/*.html", "*.gvpr"]},
packages=find_packages("src"),
entry_points={
"console_scripts": [

View File

@ -107,32 +107,36 @@ def generate_html_output(
)
# generate BOM table
# generate BOM header (may be at the top or bottom of the table)
bom_header_html = " <tr>\n"
for item in bom[0]:
th_class = f"bom_col_{item.lower()}"
bom_header_html = f'{bom_header_html} <th class="{th_class}">{item}</th>\n'
bom_header_html = f"{bom_header_html} </tr>\n"
if bom:
# generate BOM header (may be at the top or bottom of the table)
bom_header_html = " <tr>\n"
for item in bom[0]:
th_class = f"bom_col_{item.lower()}"
bom_header_html = f'{bom_header_html} <th class="{th_class}">{item}</th>\n'
bom_header_html = f"{bom_header_html} </tr>\n"
# generate BOM contents
bom_contents = []
for row in bom[1:]:
row_html = " <tr>\n"
for i, item in enumerate(row):
td_class = f"bom_col_{bom[0][i].lower()}"
row_html = f'{row_html} <td class="{td_class}">{item if item is not None else ""}</td>\n'
row_html = f"{row_html} </tr>\n"
bom_contents.append(row_html)
# generate BOM contents
bom_contents = []
for row in bom[1:]:
row_html = " <tr>\n"
for i, item in enumerate(row):
td_class = f"bom_col_{bom[0][i].lower()}"
row_html = f'{row_html} <td class="{td_class}">{item if item is not None else ""}</td>\n'
row_html = f"{row_html} </tr>\n"
bom_contents.append(row_html)
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"
)
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"
)
else:
bom_html = ""
bom_html_reversed = ""
# prepare simple replacements
replacements = {