aboutsummaryrefslogtreecommitdiff
path: root/src/ee/part
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-05-14 23:08:20 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-05-14 23:08:20 +0200
commit702d7900b646a9d873e6eaa4c61088c618eba9f1 (patch)
tree144689c62b77622cefee5b47d6bb0d91095082f0 /src/ee/part
parent2cdf0c4b9865f025e52938fb9b772cc79319db09 (diff)
downloadee-python-702d7900b646a9d873e6eaa4c61088c618eba9f1.tar.gz
ee-python-702d7900b646a9d873e6eaa4c61088c618eba9f1.tar.bz2
ee-python-702d7900b646a9d873e6eaa4c61088c618eba9f1.tar.xz
ee-python-702d7900b646a9d873e6eaa4c61088c618eba9f1.zip
ee.logging: New module to handle logging. Need something better for
messages too. create-bom: Resolving parts from their value fact too.
Diffstat (limited to 'src/ee/part')
-rw-r--r--src/ee/part/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ee/part/__init__.py b/src/ee/part/__init__.py
index 43e4cfa..ff6c7f1 100644
--- a/src/ee/part/__init__.py
+++ b/src/ee/part/__init__.py
@@ -203,6 +203,18 @@ class Part(object):
def supplier(self) -> str:
return self.xml.supplierProp
+ @property
+ def printable_reference(self):
+ for refs, value in [(self.get_schematic_references(), lambda sr: sr.referenceProp),
+ (self.get_part_references(), lambda pr: pr.part_uriProp),
+ (self.get_mpns(), lambda mpn: mpn.valueProp),
+ (self.get_spns(), lambda spn: spn.valueProp)]:
+ ref = next(iter(refs), None)
+ if ref:
+ return value(ref)
+
+ return self.uri
+
# Part number ref
def add_part_reference(self, uri):
@@ -366,6 +378,9 @@ class PartDb(object):
def size(self) -> int:
return len(self.parts)
+ def __len__(self):
+ return self.size()
+
@property
def has_assembly(self):
return self._assembly is not None