Skip to content

Commit

Permalink
Add length_unit
Browse files Browse the repository at this point in the history
- partial fix for wireviz#7
- based on and closes wireviz#161 and wireviz#162
  • Loading branch information
stevegt authored and kvid committed Nov 15, 2020
1 parent b4a77e8 commit 8cd3e2d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Cable:
gauge_unit: Optional[str] = None
show_equiv: bool = False
length: float = 0
lengthunit: Optional[str] = None
length_unit: Optional[str] = None
color: Optional[Color] = None
wirecount: Optional[int] = None
shield: Union[bool, Color] = False
Expand Down Expand Up @@ -216,8 +216,8 @@ def __post_init__(self) -> None:

self.connections = []

if self.lengthunit is None: #Default wire length units to meters if left undeclared
self.lengthunit = 'm'
if self.length_unit is None: #Default wire length units to meters if left undeclared
self.length_unit = 'm'

if self.wirecount: # number of wires explicitly defined
if self.colors: # use custom color palette (partly or looped if needed)
Expand Down
2 changes: 1 addition & 1 deletion src/wireviz/Harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def create_graph(self) -> Graph:
f'{cable.wirecount}x' if cable.show_wirecount else None,
f'{cable.gauge} {cable.gauge_unit}{awg_fmt}' if cable.gauge else None,
'+ S' if cable.shield else None,
f'{cable.length} {cable.lengthunit}' if cable.length > 0 else None,
f'{cable.length} {cable.length_unit}' if cable.length > 0 else None,
cable.color, html_colorbar(cable.color)],
'<!-- wire table -->',
[html_image(cable.image)],
Expand Down
2 changes: 1 addition & 1 deletion src/wireviz/wv_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def generate_bom(harness):
+ (f' x {cable.gauge} {cable.gauge_unit}' if cable.gauge else ' wires')
+ (' shielded' if cable.shield else ''))
bom_entries.append({
'item': description, 'qty': cable.length, 'unit': cable.lengthunit, 'designators': cable.name if cable.show_name else None,
'item': description, 'qty': cable.length, 'unit': cable.length_unit, 'designators': cable.name if cable.show_name else None,
'manufacturer': cable.manufacturer, 'mpn': cable.mpn, 'pn': cable.pn
})
else:
Expand Down

0 comments on commit 8cd3e2d

Please sign in to comment.