aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-07-16 11:36:29 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-07-16 11:36:29 +0200
commit2c9386bf9f1d465907903e7da79663b5b7e30ace (patch)
treee98984548dd80758e8ffb69cbe9e20f83f6229d7 /src/ee/kicad
parent6f34648cf13a8710c767d553e3313985f5d3fa28 (diff)
downloadee-python-2c9386bf9f1d465907903e7da79663b5b7e30ace.tar.gz
ee-python-2c9386bf9f1d465907903e7da79663b5b7e30ace.tar.bz2
ee-python-2c9386bf9f1d465907903e7da79663b5b7e30ace.tar.xz
ee-python-2c9386bf9f1d465907903e7da79663b5b7e30ace.zip
wip
Diffstat (limited to 'src/ee/kicad')
-rw-r--r--src/ee/kicad/doit.py63
1 files changed, 21 insertions, 42 deletions
diff --git a/src/ee/kicad/doit.py b/src/ee/kicad/doit.py
index 44abc61..a1405d4 100644
--- a/src/ee/kicad/doit.py
+++ b/src/ee/kicad/doit.py
@@ -9,7 +9,7 @@ class KicadDoitTasks(object):
"kicad_pcb": None,
"gerber_dir": None,
"gerber_zip": None,
- "components_dir": None,
+ "sch_object_set_dir": None,
})
def __init__(self, *args, **kwargs):
@@ -57,68 +57,47 @@ class KicadDoitTasks(object):
"file_dep": [kicad_pcb],
})
- components_dir = self.config["components_dir"]
- if sch and components_dir:
- tasks.append(task_sch_to_component_files(sch, components_dir))
+ 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))
for t in tasks:
yield t
-
-def task_sch_to_component_files(sch, components_dir):
+def task_create_kicad_sch_objects(sch, object_set_dir):
def action():
import ee.kicad
from ee.kicad.model import Component, ComponentField
import csv
import configparser
- from ee.fact import Fact
+ import ee.fact as fact
schematics = ee.kicad.read_schematics(sch)
cs = [c for c in schematics.components]
- os.makedirs(components_dir, exist_ok=True)
+ os.makedirs(object_set_dir, exist_ok=True)
# TODO: remove directory?
+ oset = fact.ObjectSet()
+ oset.read(object_set_dir)
for c in cs:
- path = os.path.join(components_dir, "{}.ini".format(c.timestamp))
- ini = configparser.ConfigParser(interpolation = None)
- if os.path.isfile(path) and ini.read(path) != [path]:
- print("Could not load component file: {}".format(path))
- return False
-# if ini.has_section("kicad-schematic"):
-# ini.remove_section("kicad-schematic")
-# ini.add_section("kicad-schematic")
-# ini.set("kicad-schematic", "ref", c.ref)
-# ini.set("kicad-schematic", "ref-type", c.ref_type)
- fact = Fact("schematic-symbol")
- ks = fact.view("kicad-schematic")
- ks.set("ref", c.ref)
- ks.set("ref-type", c.ref_type)
+ o = oset.create_object(c.timestamp)
+ o.set("ref", c.ref)
+ o.set("ref-type", c.ref_type)
if c.has_ref_num:
-# ini.set("kicad-schematic", "ref-num", str(c.ref_num))
- ks.set("ref-num", str(c.ref_num))
-# ini.set("kicad-schematic", "value", c.value)
- ks.set("value", c.value)
+ o.set("ref-num", str(c.ref_num))
+ o.set("value", c.value)
if c.footprint:
-# ini.set("kicad-schematic", "footprint", c.footprint)
- ks.set("footprint", c.footprint)
-
- fields = [f for f in c.fields if f.value and f.name not in ComponentField.names]
+ o.set("footprint", c.footprint)
- if fields:
-# if ini.has_section("kicad-fields"):
-# ini.remove_section("kicad-fields")
-# ini.add_section("kicad-fields")
- kf = fact.kv("kicad-fields")
- for f in fields:
- kf.set(f.name, str(f.value))
+ for f in c.fields:
+ if f.value and f.name not in ComponentField.names:
+ o.set(f.name, str(f.value))
- with open(path, "w", newline="") as f:
-# ini.write(f)
- fact.write(f)
+ oset.write(object_set_dir)
- component_files_cookie = "{}/components.cookie".format(components_dir)
+ component_files_cookie = "{}/kicad-sch.cookie".format(object_set_dir)
gen_cookie = "date > %(targets)s"
return {
- "name": "sch_to_component_files",
+ "name": "create-kicad-sch-objects",
"file_dep": [sch],
"actions": [action, gen_cookie],
"targets": [component_files_cookie],