Add unpopulated option to additional components qty multiplier

This commit is contained in:
Jeremy Ruhland (hatchery) 2022-12-11 18:19:38 -08:00 committed by Daniel Rojas
parent 2ac80f3ca6
commit df4a4188ba
2 changed files with 4 additions and 1 deletions

View File

@ -408,6 +408,7 @@ Parts can be added to a connector or cable in the section `<additional-component
# when used in a connector: # when used in a connector:
# pincount number of pins of connector # pincount number of pins of connector
# populated number of populated positions in a connector # populated number of populated positions in a connector
# unpopulated number of unpopulated positions
# when used in a cable: # when used in a cable:
# wirecount number of wires of cable/bundle # wirecount number of wires of cable/bundle
# terminations number of terminations on a cable/bundle # terminations number of terminations on a cable/bundle

View File

@ -18,7 +18,7 @@ MultilineHypertext = (
Designator = PlainText # Case insensitive unique name of connector or cable Designator = PlainText # Case insensitive unique name of connector or cable
# Literal type aliases below are commented to avoid requiring python 3.8 # Literal type aliases below are commented to avoid requiring python 3.8
ConnectorMultiplier = PlainText # = Literal['pincount', 'populated'] ConnectorMultiplier = PlainText # = Literal['pincount', 'populated', 'unpopulated']
CableMultiplier = ( CableMultiplier = (
PlainText # = Literal['wirecount', 'terminations', 'length', 'total_length'] PlainText # = Literal['wirecount', 'terminations', 'length', 'total_length']
) )
@ -232,6 +232,8 @@ class Connector:
return self.pincount return self.pincount
elif qty_multiplier == "populated": elif qty_multiplier == "populated":
return sum(self.visible_pins.values()) return sum(self.visible_pins.values())
elif qty_multiplier == 'unpopulated':
return (self.pincount - sum(self.visible_pins.values()))
else: else:
raise ValueError( raise ValueError(
f"invalid qty multiplier parameter for connector {qty_multiplier}" f"invalid qty multiplier parameter for connector {qty_multiplier}"