Skip to content

Commit

Permalink
Add bom ignore option for cables and connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Ward committed Sep 17, 2020
1 parent df90d83 commit 716cc06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):

Expand Down
4 changes: 2 additions & 2 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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())
Expand Down

0 comments on commit 716cc06

Please sign in to comment.