Skip to content

Commit

Permalink
Add extra components to connector nodes in graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Ward committed Sep 17, 2020
1 parent db2bfdd commit 67dc73a
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,29 @@ def create_graph(self) -> Graph:
html_line_breaks(connector.subtype),
f'{connector.pincount}-pin' if connector.show_pincount else None,
connector.color, '<!-- colorbar -->' if connector.color else None],
'<!-- connector table -->' if connector.style != 'simple' else None,
[html_line_breaks(connector.notes)]]
'<!-- connector table -->' if connector.style != 'simple' else None]
if connector.additional_components is not None:
rows.append(["Additional components"])
for extra in connector.additional_components:
if 'qty' in extra:
if isinstance(extra['qty'], int) or isinstance(extra['qty'], float):
qty = extra['qty']
else: # check for special quantities
if extra['qty'] == 'pincount':
qty = connector.pincount
elif extra['qty'] == 'connectioncount':
qty = sum(1 for value in connector.visible_pins.values() if value is True)
else:
raise ValueError('invalid aty parameter')
else:
qty = 1
rows.append([extra["type"], qty])
rows.append([extra["manufacturer"],
f'MPN: {extra["manufacturer_part_number"]}' if "manufacturer_part_number" in extra else None,
f'IPN: {extra["internal_part_number"]}' if "internal_part_number" in extra else None],)
rows.append([f'P/N: {extra["pn"]}' if extra["pn"] else None,
html_line_breaks(manufacturer_info_field(extra.get("manufacturer", None), extra.get("mpn", None)))])
rows.append([html_line_breaks(connector.notes)])
html.extend(nested_html_table(rows))

if connector.color: # add color bar next to color info, if present
Expand Down

0 comments on commit 67dc73a

Please sign in to comment.