Reformat aditional component rendering in conector and cable nodes
This commit is contained in:
parent
983c322bf8
commit
0e929fe85a
@ -8,7 +8,7 @@ from wireviz.wv_colors import get_color_hex
|
|||||||
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \
|
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \
|
||||||
nested_html_table, flatten2d, index_if_list, html_line_breaks, \
|
nested_html_table, flatten2d, index_if_list, html_line_breaks, \
|
||||||
graphviz_line_breaks, remove_line_breaks, open_file_read, open_file_write, \
|
graphviz_line_breaks, remove_line_breaks, open_file_read, open_file_write, \
|
||||||
html_colorbar, html_image, html_caption, manufacturer_info_field
|
html_colorbar, html_image, html_caption, manufacturer_info_field, component_table_entry
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from typing import List
|
from typing import List
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -110,10 +110,8 @@ class Harness:
|
|||||||
elif extra['qty_multiplier'] == 'populated':
|
elif extra['qty_multiplier'] == 'populated':
|
||||||
qty *= sum(1 for value in connector.visible_pins.values() if value is True)
|
qty *= sum(1 for value in connector.visible_pins.values() if value is True)
|
||||||
else:
|
else:
|
||||||
raise ValueError('invalid qty parameter {}'.format(extra["qty_multiplier'"]))
|
raise ValueError('invalid qty parameter {}'.format(extra["qty_multiplier"]))
|
||||||
rows.append([extra["type"], f'{qty} {extra.get("unit", "")}'.strip()])
|
rows.append(html_line_breaks(component_table_entry(extra.get["type"], qty, extra.get("unit", None), extra.get("pn", None), extra.get("manufacturer", None), extra.get("mpn", None))))
|
||||||
rows.append([f'P/N: {extra["pn"]}' if "pn" in extra else None,
|
|
||||||
html_line_breaks(manufacturer_info_field(extra.get("manufacturer", None), extra.get("mpn", None)))])
|
|
||||||
rows.append([html_line_breaks(connector.notes)])
|
rows.append([html_line_breaks(connector.notes)])
|
||||||
html.extend(nested_html_table(rows))
|
html.extend(nested_html_table(rows))
|
||||||
|
|
||||||
@ -203,9 +201,7 @@ class Harness:
|
|||||||
qty *= cable.length * cable.wirecount
|
qty *= cable.length * cable.wirecount
|
||||||
else:
|
else:
|
||||||
raise ValueError('invalid qty parameter {}'.format(extra["qty_multiplier"]))
|
raise ValueError('invalid qty parameter {}'.format(extra["qty_multiplier"]))
|
||||||
rows.append([extra["type"], f'{qty} {extra.get("unit", "")}'.strip()])
|
rows.append(html_line_breaks(component_table_entry(extra["type"], qty, extra.get("unit", None), extra.get("pn", None), extra.get("manufacturer", None), extra.get("mpn", None))))
|
||||||
rows.append([f'P/N: {extra["pn"]}' if "pn" in extra else None,
|
|
||||||
html_line_breaks(manufacturer_info_field(extra.get("manufacturer", None), extra.get("mpn", None)))])
|
|
||||||
rows.append([html_line_breaks(cable.notes)])
|
rows.append([html_line_breaks(cable.notes)])
|
||||||
html.extend(nested_html_table(rows))
|
html.extend(nested_html_table(rows))
|
||||||
|
|
||||||
|
|||||||
@ -181,3 +181,22 @@ def manufacturer_info_field(manufacturer, mpn):
|
|||||||
return f'{manufacturer if manufacturer else "MPN"}{": " + str(mpn) if mpn else ""}'
|
return f'{manufacturer if manufacturer else "MPN"}{": " + str(mpn) if mpn else ""}'
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def component_table_entry(type, qty, unit=None, pn=None, manufacturer=None, mpn=None):
|
||||||
|
output = f'{qty}'
|
||||||
|
if unit:
|
||||||
|
output += f' {unit}'
|
||||||
|
output += f' x {type}'
|
||||||
|
# print an extra line with part and manufacturer information if provided
|
||||||
|
manufacturer_str = manufacturer_info_field(manufacturer, mpn)
|
||||||
|
if pn or manufacturer_str:
|
||||||
|
output += '<br/>'
|
||||||
|
if pn:
|
||||||
|
output += f'P/N: {pn}'
|
||||||
|
if manufacturer_str:
|
||||||
|
output += ', '
|
||||||
|
if manufacturer_str:
|
||||||
|
output += manufacturer_str
|
||||||
|
# format the above output as left aligned text in a single visable cell
|
||||||
|
output = f'<table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr><td align="left" balign="left">{output}</td></tr></table>'
|
||||||
|
return output
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user