From 40cd5dd38a16b5d4ba21cd090c5e9abc1ae6369c Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Mon, 27 Mar 2023 17:56:07 +0200 Subject: [PATCH] Add placeholder for add.comp. PN info --- src/wireviz/wv_dataclasses.py | 4 ++++ src/wireviz/wv_graphviz.py | 27 ++++++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/wireviz/wv_dataclasses.py b/src/wireviz/wv_dataclasses.py index 35d4e5d9..41cf3c45 100644 --- a/src/wireviz/wv_dataclasses.py +++ b/src/wireviz/wv_dataclasses.py @@ -258,6 +258,10 @@ def bom_amount(self) -> NumberAndUnit: else: return self.amount + @property + def has_pn_info(self) -> bool: + return any([self.pn, self.manufacturer, self.mpn, self.supplier, self.spn]) + @dataclass class AdditionalComponent(Component): diff --git a/src/wireviz/wv_graphviz.py b/src/wireviz/wv_graphviz.py index 782d64e6..b01b40ec 100644 --- a/src/wireviz/wv_graphviz.py +++ b/src/wireviz/wv_graphviz.py @@ -113,17 +113,22 @@ def gv_additional_component_table(component): rows = [] for subitem in component.additional_components: - rows.append( - Tr( - [ - Td(bom_bubble(subitem.bom_id)), - Td(f"{subitem.bom_qty}", align="right"), - Td(f"{subitem.qty.unit if subitem.qty.unit else 'x'}", align="left"), - Td(f"{subitem.description}", align="left"), - Td(f"{subitem.note if subitem.note else ''}", align="left"), - ] - ) - ) + firstline = [ + Td(bom_bubble(subitem.bom_id)), + Td(f"{subitem.bom_qty}", align="right"), + Td(f"{subitem.qty.unit if subitem.qty.unit else 'x'}", align="left"), + Td(f"{subitem.description}", align="left"), + Td(f"{subitem.note if subitem.note else ''}", align="left"), + ] + rows.append(Tr(firstline)) + + if subitem.has_pn_info: + secondline = [ + Td("", colspan=3), + Td(f"# TODO PN string", align="left"), # TODO + Td(""), + ] + rows.append(Tr(secondline)) return Table(rows, border=1, cellborder=0, cellpadding=3, cellspacing=0)