aboutsummaryrefslogtreecommitdiff
path: root/src/ee/part
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/part')
-rw-r--r--src/ee/part/fact_keys.py3
-rw-r--r--src/ee/part/pn_part_search_list.py34
2 files changed, 20 insertions, 17 deletions
diff --git a/src/ee/part/fact_keys.py b/src/ee/part/fact_keys.py
index 668a197..075d943 100644
--- a/src/ee/part/fact_keys.py
+++ b/src/ee/part/fact_keys.py
@@ -1,3 +1,5 @@
+# "component type" is probably too broad, should be split into schematic and physical(?)
+
ee_component_type = "http://purl.org/ee/fact-type/ee-component-type"
capacitance = "http://purl.org/ee/fact-type/capacitance"
inductance = "http://purl.org/ee/fact-type/inductance"
@@ -14,5 +16,4 @@ place_part = "http://purl.org/ee/fact-type/place-part"
imperial_footprint_size = "http://purl.org/ee/fact-type/imperial-footprint-size"
-part_class = "http://purl.org/ee/fact-type/part-class"
footprint = "http://purl.org/ee/fact-type/footprint"
diff --git a/src/ee/part/pn_part_search_list.py b/src/ee/part/pn_part_search_list.py
index 343048e..7094c10 100644
--- a/src/ee/part/pn_part_search_list.py
+++ b/src/ee/part/pn_part_search_list.py
@@ -1,12 +1,21 @@
+from ee.kicad import sch_fact_types
from pathlib import Path
-from ee.part import PartDb, load_db, save_db, Part, fact_keys
+from ee.part import PartDb, load_db, save_db, Part, fact_keys, common_fact_types
from ee.xml import types, uris
__all__ = ["pn_part_search_list"]
-ignored_part_classes = [
- "mechanical"
+ignored_ee_component_types = [
+ "mechanical",
+ uris.NET_TIE,
+ uris.TEST_POINT,
+]
+
+ignored_part_classes_for_value_based_lookups = [
+ uris.CAPACITOR,
+ uris.INDUCTOR,
+ uris.RESISTOR,
]
@@ -18,18 +27,11 @@ def valid_pns(part: Part):
def get_value(part: Part):
"""Check if the part has a value and it is not a resistor, capacitor or inductor. Their value is not useful for a
part number-based lookup"""
- value = part.find_fact(uris.make_fact_key("value"))
-
- if value is None:
- return
-
- typ = part.find_fact(uris.make_fact_key("type"))
- if typ is None:
- return
- # if type is Zener, it's value could be a voltage
+ value, typ = part.facts.get_values(sch_fact_types.value, common_fact_types.ee_component_type)
- return value.valueProp if typ.valueProp not in (uris.RESISTOR, uris.CAPACITOR, uris.INDUCTOR) else None
+ if typ not in ignored_part_classes_for_value_based_lookups:
+ return value
def pn_part_search_list(in_path: Path, out_path: Path, supplier: str):
@@ -44,9 +46,9 @@ def pn_part_search_list(in_path: Path, out_path: Path, supplier: str):
refs = [ref.referenceProp for ref in part.get_schematic_references()]
- part_class = part.find_fact(fact_keys.part_class)
- if part_class:
- if part_class.valueProp in ignored_part_classes:
+ component_type = part.facts.get_value(fact_keys.ee_component_type)
+ if component_type:
+ if component_type in ignored_ee_component_types:
skipped.append(refs)
continue