Skip to content

Commit

Permalink
Add unpopulated option to additional components qty multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Ruhland (hatchery) authored and 17o2 committed Apr 16, 2024
1 parent 2ac80f3 commit df4a418
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ Parts can be added to a connector or cable in the section `<additional-component
# when used in a connector:
# pincount number of pins of connector
# populated number of populated positions in a connector
# unpopulated number of unpopulated positions
# when used in a cable:
# wirecount number of wires of cable/bundle
# terminations number of terminations on a cable/bundle
Expand Down
4 changes: 3 additions & 1 deletion src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Designator = PlainText # Case insensitive unique name of connector or cable

# Literal type aliases below are commented to avoid requiring python 3.8
ConnectorMultiplier = PlainText # = Literal['pincount', 'populated']
ConnectorMultiplier = PlainText # = Literal['pincount', 'populated', 'unpopulated']
CableMultiplier = (
PlainText # = Literal['wirecount', 'terminations', 'length', 'total_length']
)
Expand Down Expand Up @@ -232,6 +232,8 @@ def get_qty_multiplier(self, qty_multiplier: Optional[ConnectorMultiplier]) -> i
return self.pincount
elif qty_multiplier == "populated":
return sum(self.visible_pins.values())
elif qty_multiplier == 'unpopulated':
return (self.pincount - sum(self.visible_pins.values()))
else:
raise ValueError(
f"invalid qty multiplier parameter for connector {qty_multiplier}"
Expand Down

0 comments on commit df4a418

Please sign in to comment.