From f549988a1988fb63bdcadec83722124c36a911c1 Mon Sep 17 00:00:00 2001 From: KV Date: Thu, 25 Mar 2021 23:13:28 +0100 Subject: [PATCH] Cache the BOM entry key in the entry itself --- src/wireviz/wv_bom.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wireviz/wv_bom.py b/src/wireviz/wv_bom.py index c1667b5..d782778 100644 --- a/src/wireviz/wv_bom.py +++ b/src/wireviz/wv_bom.py @@ -49,7 +49,9 @@ def get_additional_component_bom(component: Union[Connector, Cable]) -> List[BOM def bom_types_group(entry: BOMEntry) -> BOMKey: """Return a tuple of string values from the dict that must be equal to join BOM entries.""" - return tuple(clean_whitespace(make_str(entry.get(key))) for key in ('description', 'unit', 'manufacturer', 'mpn', 'pn')) + if 'key' not in entry: + entry['key'] = tuple(clean_whitespace(make_str(entry.get(k))) for k in ('description', 'unit', 'manufacturer', 'mpn', 'pn')) + return entry['key'] def generate_bom(harness: "Harness") -> List[BOMEntry]: """Return a list of BOM entries generated from the harness."""