From 716cc06ea9be0df11b61b8f1768e71625508a46d Mon Sep 17 00:00:00 2001 From: Tyler Ward Date: Sun, 19 Jul 2020 22:57:05 +0100 Subject: [PATCH] Add bom ignore option for cables and connectors --- src/wireviz/DataClasses.py | 2 ++ src/wireviz/Harness.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 6b3b1e36..808db376 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -27,6 +27,7 @@ class Connector: hide_disconnected_pins: bool = False autogenerate: bool = False loops: List[Any] = field(default_factory=list) + ignore_in_bom: bool = False def __post_init__(self): self.ports_left = False @@ -96,6 +97,7 @@ class Cable: color_code: Optional[str] = None show_name: bool = True show_wirecount: bool = True + ignore_in_bom: bool = False def __post_init__(self): diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index af7946e3..2cb4144b 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -336,7 +336,7 @@ def bom(self): bom_extra = [] # connectors connector_group = lambda c: (c.type, c.subtype, c.pincount, c.manufacturer, c.mpn, c.pn) - for group in Counter([connector_group(v) for v in self.connectors.values()]): + for group in Counter([connector_group(v) for v in self.connectors.values() if v.ignore_in_bom is not True]): items = {k: v for k, v in self.connectors.items() if connector_group(v) == group} shared = next(iter(items.values())) designators = list(items.keys()) @@ -355,7 +355,7 @@ def bom(self): # TODO: If category can have other non-empty values than 'bundle', maybe it should be part of item name? # The category needs to be included in cable_group to keep the bundles excluded. cable_group = lambda c: (c.category, c.type, c.gauge, c.gauge_unit, c.wirecount, c.shield, c.manufacturer, c.mpn, c.pn) - for group in Counter([cable_group(v) for v in self.cables.values() if v.category != 'bundle']): + for group in Counter([cable_group(v) for v in self.cables.values() if v.category != 'bundle' and v.ignore_in_bom is not True]): items = {k: v for k, v in self.cables.items() if cable_group(v) == group} shared = next(iter(items.values())) designators = list(items.keys())