diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ee/digikey/__init__.py | 3 | ||||
-rw-r--r-- | src/ee/kicad/make_bom.py | 2 | ||||
-rw-r--r-- | src/ee/part/fact_keys.py | 3 | ||||
-rw-r--r-- | src/ee/part/pn_part_search_list.py | 34 | ||||
-rw-r--r-- | src/ee/souffle/kicad.dl | 24 | ||||
-rw-r--r-- | src/ee/xml/uris.py | 3 |
6 files changed, 51 insertions, 18 deletions
diff --git a/src/ee/digikey/__init__.py b/src/ee/digikey/__init__.py index 4c4adce..87860b9 100644 --- a/src/ee/digikey/__init__.py +++ b/src/ee/digikey/__init__.py @@ -498,6 +498,9 @@ class DigikeyParser(object): @staticmethod def ensure_absolute_url(origin_url, url): + if url is None: + return + if not url.startswith("http"): o = urllib.parse.urlparse(origin_url) url = "{}://{}{}".format(o.scheme, o.netloc, url) diff --git a/src/ee/kicad/make_bom.py b/src/ee/kicad/make_bom.py index de1412c..ded3e5f 100644 --- a/src/ee/kicad/make_bom.py +++ b/src/ee/kicad/make_bom.py @@ -66,7 +66,7 @@ def work(sch, out: Path, project_uuid: UUID, new_mode, pretty): part.facts.add(sch_fact_types.footprint_name, footprint) for f in c.named_fields: - if f.is_custom and f.value is not None and len(f.value): + if f.is_custom and f.value is not None and len(f.value) and f.value != "~": part.facts.add(sch_fact_types.make_custom_field_key(f.name), f.value) parts.add_entry(part, True) 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 diff --git a/src/ee/souffle/kicad.dl b/src/ee/souffle/kicad.dl index 16b76dd..e01cefe 100644 --- a/src/ee/souffle/kicad.dl +++ b/src/ee/souffle/kicad.dl @@ -42,3 +42,27 @@ fact(Ref, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/ fact(Ref, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#inductor") :- inductor_lib(lib), fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib). + +.decl net_tie_symbol(lib:symbol, name:symbol) +net_tie_symbol("Device", "Net-Tie_2"). +net_tie_symbol("Device", "Net-Tie_3"). +net_tie_symbol("Device", "Net-Tie_3_Tee"). +net_tie_symbol("Device", "Net-Tie_4"). +net_tie_symbol("Device", "Net-Tie_4_Cross"). + +fact(Ref, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#net-tie") :- + net_tie_symbol(lib, name), + fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib), + fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name). + +.decl test_point_symbol(lib:symbol, name:symbol) +test_point_symbol("Connector", "TestPoint"). +test_point_symbol("Connector", "TestPoint_2Pole"). +test_point_symbol("Connector", "TestPoint_Alt"). +test_point_symbol("Connector", "TestPoint_Flag"). +test_point_symbol("Connector", "TestPoint_Probe"). + +fact(Ref, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#test-point") :- + test_point_symbol(lib, name), + fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib), + fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name). diff --git a/src/ee/xml/uris.py b/src/ee/xml/uris.py index 355df83..d2e3f5b 100644 --- a/src/ee/xml/uris.py +++ b/src/ee/xml/uris.py @@ -9,6 +9,9 @@ INDUCTOR = "http://purl.org/ee/part-type#inductor" CRYSTAL = "http://purl.org/ee/part-type#inductor" TRANSISTOR = "http://purl.org/ee/part-type#transistor" +NET_TIE = "http://purl.org/ee/part-type#net-tie" +TEST_POINT = "http://purl.org/ee/part-type#test-point" + _DIGIKEY_FACT_KEY_PREFIX = "http://purl.org/ee/digikey-fact-key#" |