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", keywords="cable connector hardware harness wiring wiring-diagram wiring-harness",
url=APP_URL, url=APP_URL,
package_dir={"": "src"}, package_dir={"": "src"},
package_data={CMD_NAME: ["templates/*.html"]}, package_data={CMD_NAME: ["templates/*.html", "*.gvpr"]},
packages=find_packages("src"), packages=find_packages("src"),
entry_points={ entry_points={
"console_scripts": [ "console_scripts": [

View File

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