aboutsummaryrefslogtreecommitdiff
path: root/src/ee/part
diff options
context:
space:
mode:
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)