aboutsummaryrefslogtreecommitdiff
path: root/src/ee/part/__init__.py
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/__init__.py
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/__init__.py')
-rw-r--r--src/ee/part/__init__.py11
1 files changed, 11 insertions, 0 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):