aboutsummaryrefslogtreecommitdiff
path: root/src/ee
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-07-19 23:00:13 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-07-19 23:00:13 +0200
commit067cd0ef6a7e031ea839c7d118da002267df95b3 (patch)
tree5f1974a427e9bffb5c639a052acaf665c5bca033 /src/ee
parenta30b71772e7eb831e8d87759172a02e79f9673c4 (diff)
downloadee-python-067cd0ef6a7e031ea839c7d118da002267df95b3.tar.gz
ee-python-067cd0ef6a7e031ea839c7d118da002267df95b3.tar.bz2
ee-python-067cd0ef6a7e031ea839c7d118da002267df95b3.tar.xz
ee-python-067cd0ef6a7e031ea839c7d118da002267df95b3.zip
wip.
Diffstat (limited to 'src/ee')
-rw-r--r--src/ee/kicad/doit.py56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/ee/kicad/doit.py b/src/ee/kicad/doit.py
index fcbcaef..29438ad 100644
--- a/src/ee/kicad/doit.py
+++ b/src/ee/kicad/doit.py
@@ -1,6 +1,5 @@
import logging
import os.path
-from typing import List
from configclass import Config
@@ -21,8 +20,12 @@ class KicadDoitTasks(object):
def __init__(self, *args, **kwargs):
self.config = self.config.make(kwargs)
- def echo(*args, **kwargs):
- logger.info("_task: args={}, kwars={}".format(args, kwargs))
+ formatter = logging.Formatter("%(levelname)s: %(message)s")
+ ch = logging.StreamHandler()
+ ch.setFormatter(formatter)
+ logger.addHandler(ch)
+
+ logger.setLevel(logging.DEBUG)
def tasks(self, *args, **kwargs):
kicad_pcb = self.config["kicad_pcb"]
@@ -36,27 +39,23 @@ class KicadDoitTasks(object):
if kicad_pcb and gerber_dir:
tasks.append(task_kicad_gerber(kicad_pcb, gerber_dir, gerber_zip))
- sch_ds = task_kicad_sch_to_data_set(dsm, sch,
- in_data_sets=[],
- out_data_set="kicad-sch-data-set") \
+ sch_ds = task_kicad_sch_to_data_set(dsm, sch) \
if sch else None
- component_ds = task_kicad_create_component_data_set(dsm,
- in_data_sets=sch_ds["targets"],
- out_data_set="raw-component") \
- if sch_ds else None
-
- pcb_ds = task_kicad_pcb_to_data_set(dsm, kicad_pcb, in_data_sets=[], out_data_set="kicad-pcb") \
+ pcb_ds = task_kicad_pcb_to_data_set(dsm, kicad_pcb) \
if kicad_pcb else None
- tasks = [sch_ds, component_ds, pcb_ds]
- return (t for t in tasks if t)
+ component_ds = task_kicad_create_component_data_set(dsm) \
+ if sch_ds else None
+
+ tasks = [component_ds, sch_ds, pcb_ds,]
+ return tasks
def task_kicad_gerber(kicad_pcb: str, gerber_dir: str, gerber_zip: str, name="kicad-gerber"):
import ee.kicad
- gerber_zip = len(gerber_zip) or "{}.zip".format(gerber_dir)
+ gerber_zip = gerber_zip or "{}.zip".format(gerber_dir)
# logger.info("gerber_zip={}".format(gerber_zip))
eg = next((p for p in (os.path.join(p, "export_gerber.py") for p in ee.kicad.__path__) if os.path.isfile(p)), None)
@@ -89,8 +88,10 @@ def task_kicad_gerber(kicad_pcb: str, gerber_dir: str, gerber_zip: str, name="ki
}
-def task_kicad_sch_to_data_set(dsm: DataSetManager, sch, in_data_sets: List[str], out_data_set,
- name="kicad-sch-to-data-set"):
+def task_kicad_sch_to_data_set(dsm: DataSetManager, sch, name="kicad-sch-to-data-set"):
+ out_data_set = "kicad-sch"
+ in_data_sets = []
+
def action():
import ee.kicad
from ee.kicad.model import ComponentField
@@ -119,21 +120,22 @@ def task_kicad_sch_to_data_set(dsm: DataSetManager, sch, in_data_sets: List[str]
}
-def task_kicad_pcb_to_data_set(dsm: DataSetManager, pcb_path, in_data_sets: List[str], out_data_set,
- name="kicad-pcb-to-data-set"):
+def task_kicad_pcb_to_data_set(dsm: DataSetManager, pcb_path, name="kicad-pcb-to-data-set"):
+ out_data_set = "kicad-pcb"
+ in_data_sets = []
+
def action():
import ee.kicad.pcb
from ee.kicad.pcb import FpText
+ logger.debug("Parsing PCB {}".format(pcb_path))
+
with dsm.create_rw(out_data_set, inputs=in_data_sets) as ds:
# [ds.delete(o) for o in ds.items(object_type="kicad-pcb-component")]
pcb: ee.kicad.pcb.KicadPcb = ee.kicad.pcb.parse(pcb_path)
for _m in pcb.modules:
m: ee.kicad.pcb.Module = _m
- logger.info("attrs")
- for s in dir(m):
- logger.info(s)
o = ds.get_object("kicad-pcb-component", m.tstamp)
@@ -154,10 +156,12 @@ def task_kicad_pcb_to_data_set(dsm: DataSetManager, pcb_path, in_data_sets: List
}
-def task_kicad_create_component_data_set(dsm: DataSetManager, in_data_sets: List[str], out_data_set,
- name="kicad-create-component-data-set"):
- def action(*args, **kwargs):
- logger.info("args={}, kwargs={}".format(args, kwargs))
+def task_kicad_create_component_data_set(dsm: DataSetManager, name="kicad-create-component-data-set"):
+ out_data_set = "components"
+ in_data_sets = ["kicad-sch", "kicad-pcb"]
+
+ def action(targets, *args, **kwargs):
+ logger.info("targets={}, args={}, kwargs={}".format(targets, args, kwargs))
with dsm.create_rw(out_data_set, inputs=in_data_sets) as ds:
items = ds.items()