aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/kicad')
-rw-r--r--src/ee/kicad/functions.py36
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):