diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-05-21 07:57:12 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-05-21 07:57:12 +0200 |
commit | c8c04a73fef2e2f365d448a067bc5a6c8b20bebb (patch) | |
tree | 1db4475641dc6f8b914e4940145be86e2a167c80 /src/ee/kicad | |
parent | 9bbb4f8f3a1d8e2bfe1f06c945081153435de940 (diff) | |
download | ee-python-c8c04a73fef2e2f365d448a067bc5a6c8b20bebb.tar.gz ee-python-c8c04a73fef2e2f365d448a067bc5a6c8b20bebb.tar.bz2 ee-python-c8c04a73fef2e2f365d448a067bc5a6c8b20bebb.tar.xz ee-python-c8c04a73fef2e2f365d448a067bc5a6c8b20bebb.zip |
o Creating a map_footprints function for digikey's footprints similar to
kicad's function.
Diffstat (limited to 'src/ee/kicad')
-rw-r--r-- | src/ee/kicad/functions.py | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/src/ee/kicad/functions.py b/src/ee/kicad/functions.py index c0d1780..a2f9f80 100644 --- a/src/ee/kicad/functions.py +++ b/src/ee/kicad/functions.py @@ -1,10 +1,8 @@ import re -import yaml import ee.kicad.model import ee.kicad.sch_fact_types as kicad_ft -from ee import EeException from ee.kicad import sch_fact_types from ee.part import Part from ee.part import common_fact_types @@ -109,38 +107,10 @@ def mpn_strategy(**kwargs): # noinspection PyUnusedLocal def map_footprint(footprint_mappings=None, **kwargs): - if footprint_mappings is None: - return None + # noinspection PyProtectedMember + from ee.part._utils import map_footprint - mappings = {} - with open(footprint_mappings, "r") as f: - doc = yaml.load(f, Loader=yaml.SafeLoader) - if not isinstance(doc, dict): - raise EeException("The footprint mappings document must be a dict.") - - if "kicad-to-common" not in doc: - raise EeException("The footprint mappings document must contain the key 'kicad-to-common'.") - - for k, v in doc["kicad-to-common"].items(): - if not isinstance(v, str): - raise EeException("Bad value for key {}, must be a string".format(k)) - - mappings[k] = v - - def on_part(part: Part) -> Part: - kicad_footprint = part.facts.get_value(kicad_ft.footprint) - - if not kicad_footprint: - return part - - footprint = mappings.get(kicad_footprint, None) - - if footprint: - part.facts.add(common_fact_types.footprint, footprint) - - return part - - return on_part + return map_footprint(footprint_mappings, "kicad-to-common", kicad_ft.footprint) def default(**kwargs): |