From 9a93d8605845304cdf14cf4f7a1f721b46481d8b Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Tue, 23 Mar 2021 11:19:20 +0100 Subject: [PATCH] remove `component_table_entry()` as separate func. to simplyfy code --- src/wireviz/Harness.py | 2 +- src/wireviz/wv_bom.py | 29 +---------------------------- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py index 117e0d9..3ad4ee0 100644 --- a/src/wireviz/Harness.py +++ b/src/wireviz/Harness.py @@ -13,7 +13,7 @@ from wireviz.DataClasses import Connector, Cable from wireviz.wv_colors import get_color_hex from wireviz.wv_gv_html import nested_html_table, html_colorbar, html_image, \ html_caption, remove_links, html_line_breaks, bom_bubble -from wireviz.wv_bom import manufacturer_info_field, component_table_entry, \ +from wireviz.wv_bom import manufacturer_info_field, \ get_additional_component_table, bom_list, generate_bom from wireviz.wv_html import generate_html_output from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, flatten2d, \ diff --git a/src/wireviz/wv_bom.py b/src/wireviz/wv_bom.py index 990e153..eca24ca 100644 --- a/src/wireviz/wv_bom.py +++ b/src/wireviz/wv_bom.py @@ -22,10 +22,6 @@ def get_additional_component_table(harness: "Harness", component: Union[Connecto if component.additional_components: # rows.append(["Additional components"]) for part in component.additional_components: - common_args = { - 'qty': part.qty * component.get_qty_multiplier(part.qty_multiplier), - 'unit': part.unit, - } # if True: # id = get_bom_index(harness.bom(), part) # rows.append(component_table_entry(f'#{id} ({part.type.rstrip()})', **common_args)) @@ -43,7 +39,7 @@ def get_additional_component_table(harness: "Harness", component: Union[Connecto columns.append(f'{manufacturer_str}' if manufacturer_str else '') columns.append(f'{part.note}' if part.note else '') - rowstr = '' + ''.join([f'{col}' for col in columns]) + '' + rowstr = '' + ''.join([f'{html_line_breaks(col)}' for col in columns]) + '' rows.append(rowstr) print(rows) @@ -160,29 +156,6 @@ def bom_list(bom: List[BOMEntry]) -> List[List[str]]: return ([[bom_headings.get(k, k.capitalize()) for k in keys]] + # Create header row with key names [[make_str(entry.get(k)) for k in keys] for entry in bom]) # Create string list for each entry row -def component_table_entry( - type: str, - qty: Union[int, float], - unit: Optional[str] = None, - pn: Optional[str] = None, - manufacturer: Optional[str] = None, - mpn: Optional[str] = None, - ) -> str: - """Return a diagram node table row string with an additional component.""" - manufacturer_str = manufacturer_info_field(manufacturer, mpn) - output = (f'{qty}' - + (f' {unit}' if unit else '') - + f' x {type}' - + ('
' if pn or manufacturer_str else '') - + (f'P/N: {pn}' if pn else '') - + (', ' if pn and manufacturer_str else '') - + (manufacturer_str or '')) - # format the above output as left aligned text in a single visible cell - # indent is set to two to match the indent in the generated html table - return f''' - {html_line_breaks(output)} - ''' - def manufacturer_info_field(manufacturer: Optional[str], mpn: Optional[str]) -> Optional[str]: """Return the manufacturer and/or the mpn in one single string or None otherwise.""" if manufacturer or mpn: