diff options
Diffstat (limited to 'src/ee')
-rw-r--r-- | src/ee/bom.py | 16 | ||||
-rw-r--r-- | src/ee/part/__init__.py | 4 | ||||
-rw-r--r-- | src/ee/souffle/kicad.dl | 5 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/ee/bom.py b/src/ee/bom.py index e12260c..cf18955 100644 --- a/src/ee/bom.py +++ b/src/ee/bom.py @@ -25,7 +25,7 @@ class BomPart(object): self.part = part ref = self.part.get_only_schematic_reference() self.ref = ref.referenceProp if ref else None - self.hits = [] + self.hits: List[Hit] = [] self.selected_part: Optional[Part] = None def add_hit(self, part, method): @@ -94,11 +94,14 @@ def create_bom(project: Project, schematic_path: Path, out_path: Path, part_dbs: sch_part_numbers = [pn.valueProp for pn in bom_part.part.get_mpns()] sch_supplier_part_numbers = [spn.valueProp for spn in bom_part.part.get_spns()] - value_fact = bom_part.part.find_fact(make_fact_key("value")) + value_fact = bom_part.part.find_fact(fact_keys.value) if value_fact: value_fact = value_fact.valueProp for supplier in suppliers: + if value_fact is not None: + pass + # Part number search pns = supplier_pn_idx.get(supplier.uri) for sch_pn in sch_part_numbers: @@ -126,9 +129,12 @@ def create_bom(project: Project, schematic_path: Path, out_path: Path, part_dbs: elif len(bom_part.hits) == 1: bom_part.selected_part = bom_part.hits[0].part else: - references = [hit.part.printable_reference for hit in bom_part.hits] - raise EeException("Multiple hits when looking for part: {}". - format(bom_part.ref, ",".join(references))) + if len(set(hit.part.uri for hit in bom_part.hits)) == 1: + bom_part.selected_part = bom_part.hits[0].part + else: + references = [hit.part.printable_reference for hit in bom_part.hits] + raise StopToolException("Multiple hits when looking for part: {}". + format(bom_part.ref, ",".join(references))) bom_parts.add_index("uri", lambda bp: bp.selected_part.uri if bp.selected_part else None) bom_parts.add_multi_index("supplier,part", lambda op: ( diff --git a/src/ee/part/__init__.py b/src/ee/part/__init__.py index deeab95..53835df 100644 --- a/src/ee/part/__init__.py +++ b/src/ee/part/__init__.py @@ -219,10 +219,10 @@ class Part(object): @property def printable_reference(self): - for refs, value in [(self.get_schematic_references(), lambda sr: sr.referenceProp), + 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)]: + (self.get_spns(), lambda spn: spn.valueProp)): ref = next(iter(refs), None) if ref: return value(ref) diff --git a/src/ee/souffle/kicad.dl b/src/ee/souffle/kicad.dl index 734811c..06633aa 100644 --- a/src/ee/souffle/kicad.dl +++ b/src/ee/souffle/kicad.dl @@ -169,3 +169,8 @@ mounting_hole(Part) :- add_fact(Part, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#mounting-hole") :- mounting_hole(Part). + +// Value + +add_fact(Part, "http://purl.org/ee/fact-type/value", value) :- + fact(Part, "http://purl.org/ee/kicad-sch-fact-type#value", value). |