aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-07-16 13:23:36 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-07-16 13:23:36 +0200
commit831485bd027eb288f52a16f2078b232553758d3c (patch)
treeec722ff3add026b5c4afa7eea96afad7c32201d9 /src/ee/kicad
parent2c9386bf9f1d465907903e7da79663b5b7e30ace (diff)
downloadee-python-831485bd027eb288f52a16f2078b232553758d3c.tar.gz
ee-python-831485bd027eb288f52a16f2078b232553758d3c.tar.bz2
ee-python-831485bd027eb288f52a16f2078b232553758d3c.tar.xz
ee-python-831485bd027eb288f52a16f2078b232553758d3c.zip
wip
Diffstat (limited to 'src/ee/kicad')
-rw-r--r--src/ee/kicad/doit.py53
1 files changed, 40 insertions, 13 deletions
diff --git a/src/ee/kicad/doit.py b/src/ee/kicad/doit.py
index a1405d4..cc9936c 100644
--- a/src/ee/kicad/doit.py
+++ b/src/ee/kicad/doit.py
@@ -9,7 +9,8 @@ class KicadDoitTasks(object):
"kicad_pcb": None,
"gerber_dir": None,
"gerber_zip": None,
- "sch_object_set_dir": None,
+ "kicad_sch_object_set_dir": None,
+ "component_object_set_dir": None,
})
def __init__(self, *args, **kwargs):
@@ -57,14 +58,19 @@ class KicadDoitTasks(object):
"file_dep": [kicad_pcb],
})
- sch_object_set_dir = self.config["sch_object_set_dir"]
- if sch and sch_object_set_dir:
- tasks.append(task_create_kicad_sch_objects(sch, sch_object_set_dir))
+ kicad_sch_object_set_dir = self.config["kicad_sch_object_set_dir"]
+ component_object_set_dir = self.config["component_object_set_dir"]
+
+ if sch and kicad_sch_object_set_dir:
+ tasks.append(task_create_kicad_sch_objects(sch, kicad_sch_object_set_dir))
+
+ if kicad_sch_object_set_dir and component_object_set_dir:
+ tasks.append(task_kicad_sch_to_component_object(kicad_sch_object_set_dir, component_object_set_dir))
for t in tasks:
yield t
-def task_create_kicad_sch_objects(sch, object_set_dir):
+def task_create_kicad_sch_objects(sch, os_dir, name="create-kicad-sch-objects"):
def action():
import ee.kicad
from ee.kicad.model import Component, ComponentField
@@ -74,10 +80,10 @@ def task_create_kicad_sch_objects(sch, object_set_dir):
schematics = ee.kicad.read_schematics(sch)
cs = [c for c in schematics.components]
- os.makedirs(object_set_dir, exist_ok=True)
+ os.makedirs(os_dir, exist_ok=True)
# TODO: remove directory?
oset = fact.ObjectSet()
- oset.read(object_set_dir)
+ oset.read(os_dir)
for c in cs:
o = oset.create_object(c.timestamp)
o.set("ref", c.ref)
@@ -92,13 +98,34 @@ def task_create_kicad_sch_objects(sch, object_set_dir):
if f.value and f.name not in ComponentField.names:
o.set(f.name, str(f.value))
- oset.write(object_set_dir)
+ oset.write(os_dir)
- component_files_cookie = "{}/kicad-sch.cookie".format(object_set_dir)
- gen_cookie = "date > %(targets)s"
return {
- "name": "create-kicad-sch-objects",
+ "name": name,
"file_dep": [sch],
- "actions": [action, gen_cookie],
- "targets": [component_files_cookie],
+ "actions": [action],
+ "targets": [os.path.join(os_dir, "object-set.ini")],
+ }
+
+def task_kicad_sch_to_component_object(kicad_sch_os_dir, component_os_dir, name="kicad-sch-to-component-object"):
+ def action():
+ import ee.fact as fact
+
+ kicad_sch_os = fact.ObjectSet()
+ kicad_sch_os.read(kicad_sch_os_dir)
+
+ os.makedirs(component_os_dir, exist_ok=True)
+ component_os = fact.ObjectSet()
+ component_os.read(component_os_dir)
+
+ for o in kicad_sch_os.items():
+ print("processing {}".format(o.key))
+
+ component_os.write(component_os_dir)
+
+ return {
+ "name": name,
+ "file_dep": [os.path.join(kicad_sch_os_dir, "object-set.ini")],
+ "actions": [action],
+ "targets": [os.path.join(component_os_dir, "object-set.ini")],
}