From 73f151ec1da4ca78d4b9326f7efc81e0fad05159 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 16 Oct 2019 08:41:29 +0200 Subject: part: Adding description property to Part. --- src/ee/part/__init__.py | 4 ++++ src/ee/tools/bom_to_csv.py | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ee/part/__init__.py b/src/ee/part/__init__.py index 53835df..975dc68 100644 --- a/src/ee/part/__init__.py +++ b/src/ee/part/__init__.py @@ -209,6 +209,10 @@ class Part(object): def underlying(self) -> types.Part: return self.xml + @property + def description(self) -> str: + return self.xml.descriptionProp + @property def uri(self) -> str: return self.xml.uriProp diff --git a/src/ee/tools/bom_to_csv.py b/src/ee/tools/bom_to_csv.py index 99aa98f..de9dead 100644 --- a/src/ee/tools/bom_to_csv.py +++ b/src/ee/tools/bom_to_csv.py @@ -37,19 +37,33 @@ check_bom(bom_parts, supplier_parts) bom = generate_bom(args.allow_incomplete, bom_parts, supplier_parts) +enable_value = False + if bom is not None: with out_path.open("w") as f: w = csv.writer(f) - w.writerow(["Quantity", "MPN", "SPN", "References"]) + fields = ["Part URI", "Description", "MPN", "SPN", "Quantity", "References"] + + if enable_value: + fields.append("Value") + + w.writerow(fields) for line in bom.lines: mpn = line.part.get_only_mpn() spn = line.part.get_only_spn() row = [ - str(len(line.refs)), + line.part.uri, + line.part.description, mpn.valueProp if mpn else "", spn.valueProp if spn else "", + str(len(line.refs)), join_refs(line.refs), ] + + if enable_value: + value = "" # line.part.facts.get_value() + row.append(value) + w.writerow(row) -- cgit v1.2.3