aboutsummaryrefslogtreecommitdiff
path: root/src/ee/part
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-04-09 06:03:33 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-04-13 05:58:28 +0200
commita00dcfc7f6d12442fca8c5b7d43f12b707f0c877 (patch)
tree537fe862e4a8946a1346e87f97ac77772db56e17 /src/ee/part
parent0232e0f992c3a03fe163b437cc1c1d631c8ddb83 (diff)
downloadee-python-a00dcfc7f6d12442fca8c5b7d43f12b707f0c877.tar.gz
ee-python-a00dcfc7f6d12442fca8c5b7d43f12b707f0c877.tar.bz2
ee-python-a00dcfc7f6d12442fca8c5b7d43f12b707f0c877.tar.xz
ee-python-a00dcfc7f6d12442fca8c5b7d43f12b707f0c877.zip
o Renaming part-create-distributor-search-list to pn-part-search-list.
Making the search more narrow, it is only responsible to find parts based on MPN or SPN.
Diffstat (limited to 'src/ee/part')
-rw-r--r--src/ee/part/__init__.py11
-rw-r--r--src/ee/part/pn_part_search_list.py (renamed from src/ee/part/create_distributor_search_list.py)8
2 files changed, 15 insertions, 4 deletions
diff --git a/src/ee/part/__init__.py b/src/ee/part/__init__.py
index 7a58f75..fbf0838 100644
--- a/src/ee/part/__init__.py
+++ b/src/ee/part/__init__.py
@@ -56,6 +56,17 @@ class Part(object):
def get_part_references(self) -> List[types.PartReference]:
return self.xml.referencesProp.part_referenceProp
+ def get_exactly_one_part_reference(self) -> types.PartReference:
+ refs = self.get_part_references()
+ if len(refs) == 0:
+ raise EeException("This part does not contain any part references{}".
+ format(", uri=" + self.uri if self.uri else ""))
+ if len(refs) != 1:
+ raise EeException("This part does not contain exactly one part reference: {}".
+ format(", ".join([ref.part_uriProp for ref in refs])))
+
+ return refs[0]
+
# Schematic references
def add_schematic_reference(self, ref):
diff --git a/src/ee/part/create_distributor_search_list.py b/src/ee/part/pn_part_search_list.py
index 8d70e3e..049d0b8 100644
--- a/src/ee/part/create_distributor_search_list.py
+++ b/src/ee/part/pn_part_search_list.py
@@ -3,18 +3,18 @@ from pathlib import Path
from ee.part import PartDb, load_db, save_db, Part, fact_keys
from ee.xml import types
-__all__ = ["create_distributor_search_list"]
+__all__ = ["pn_part_search_list"]
ignored_part_classes = [
"mechanical"
]
-def create_distributor_search_list(in_path: Path, out_path: Path):
+def pn_part_search_list(in_path: Path, out_path: Path, supplier: str):
in_parts = load_db(in_path)
out_parts = PartDb()
- print("loaded {} existing parts".format(in_parts.size()))
+ # print("loaded {} existing parts".format(in_parts.size()))
for xml in in_parts.iterparts():
part = Part(xml)
@@ -40,5 +40,5 @@ def create_distributor_search_list(in_path: Path, out_path: Path):
out_parts.add_entry(new_part, True)
- print("Saving {} work parts".format(out_parts.size()))
+ # print("Saving {} work parts".format(out_parts.size()))
save_db(out_path, out_parts)