From e1ea1f1892fda873522a0294d32b496110d2e8f6 Mon Sep 17 00:00:00 2001 From: Steve Traugott Date: Mon, 5 Oct 2020 00:26:38 -0700 Subject: [PATCH] Add length_unit - partial fix for #7 - based on and closes #161 and #162 --- src/wireviz/DataClasses.py | 6 +++--- src/wireviz/Harness.py | 2 +- src/wireviz/wv_bom.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 555ba7e7..c2d680d6 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -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 @@ -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) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index f580dfe1..9d83a3df 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -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)], '', [html_image(cable.image)], diff --git a/src/wireviz/wv_bom.py b/src/wireviz/wv_bom.py index b7f05e08..02b506c8 100644 --- a/src/wireviz/wv_bom.py +++ b/src/wireviz/wv_bom.py @@ -72,7 +72,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: