diff options
-rw-r--r-- | demo/doit/dodo.py | 61 | ||||
-rw-r--r-- | src/ee/doit.py | 4 | ||||
-rw-r--r-- | src/ee/ds/__init__.py | 2 | ||||
-rw-r--r-- | src/ee/ds/doit.py | 14 | ||||
-rw-r--r-- | test/doit/test_doit.py | 4 |
5 files changed, 42 insertions, 43 deletions
diff --git a/demo/doit/dodo.py b/demo/doit/dodo.py index c2b8194..780f2b9 100644 --- a/demo/doit/dodo.py +++ b/demo/doit/dodo.py @@ -1,46 +1,55 @@ -import ee.bom.doit -import ee.digikey.doit -import ee.doit -import ee.kicad.doit -# noinspection PyUnresolvedReferences from ee.bom.doit import * -# noinspection PyUnresolvedReferences from ee.digikey.doit import * +from ee.doit import configure_logging from ee.ds import DataSetManager from ee.kicad.doit import * -prj = "demo" -sch = "{}.sch".format(prj) -kicad_pcb = "{}.kicad_pcb".format(prj) + +def configure_kicad(): + from ee.kicad.doit import doit_config, init + doit_config.configure(data_set_manager=dsm) + doit_config.append_in_data_set_for_task(task_kicad_create_component_data_set, kicad_footprint) + init(sch=sch, kicad_pcb=kicad_pcb, gerber_dir="gerber", ) + + +def configure_bom(): + from ee.bom.doit import doit_config + doit_config.configure(data_set_manager=dsm) + + +def configure_digikey(): + from ee.digikey.doit import doit_config + doit_config.configure(data_set_manager=dsm) + + +# Configure DoIt +configure_logging() DOIT_CONFIG = {'check_file_uptodate': 'timestamp'} -ee.doit.configure_logging() +prj = "demo" +sch = "{}.sch".format(prj) +kicad_pcb = "{}.kicad_pcb".format(prj) dsm = DataSetManager("ee") kicad_footprint = "kicad-footprint" -dsm.add_ds("csv", kicad_footprint, "kicad-footprint-mapping", path="ee/kicad-footprint.csv") - -ee.kicad.doit.doit_config.change_data_sets_for_task(task_kicad_create_component_data_set, lambda ds: ds + [kicad_footprint]) +dsm.register_ds("csv", kicad_footprint, "kicad-footprint-mapping", path="ee/kicad-footprint.csv") -ee.kicad.doit.init( - data_set_manager=dsm, - sch=sch, - kicad_pcb=kicad_pcb, - gerber_dir="gerber", -) +configure_kicad() +configure_bom() +configure_digikey() -ee.bom.doit.init( - data_set_manager=dsm, -) -ee.digikey.doit.doit_config.configure(data_set_manager=dsm) +def task_orders(): + import ee.bom.doit + import ee.digikey.doit + bom_cfg = ee.bom.doit.doit_config + digikey_cfg = ee.digikey.doit.doit_config -def task_orders(): - data_sets = [ee.bom.doit.doit_config.out_data_set_for(task_bom), - ee.digikey.doit.doit_config.out_data_set_for(task_digikey_resolve_schematic_components)] + data_sets = [bom_cfg.out_data_set_for(task_bom), + digikey_cfg.out_data_set_for(task_digikey_resolve_schematic_components)] yield create_task_order_csv( output_file="ee/order.csv", diff --git a/src/ee/doit.py b/src/ee/doit.py index c0a01ea..a89fdf7 100644 --- a/src/ee/doit.py +++ b/src/ee/doit.py @@ -50,3 +50,7 @@ class DoItConfig(object): def change_data_sets_for_task(self, task, _callable): ds = self._data_sets[task] ds[1] = _callable(ds[1]) + + def append_in_data_set_for_task(self, task, *data_sets: str): + ds = self._data_sets[task] + ds[1] = ds[1] + list(data_sets) diff --git a/src/ee/ds/__init__.py b/src/ee/ds/__init__.py index adf741f..5b4da4d 100644 --- a/src/ee/ds/__init__.py +++ b/src/ee/ds/__init__.py @@ -277,7 +277,7 @@ class DataSetManager(object): return ds - def add_ds(self, ds_type: str, name: str, object_type: str, path: str = None): + def register_ds(self, ds_type: str, name: str, object_type: str, path: str = None): if ds_type == "csv": if name in self._csv: raise Exception("Data source already exists: {}".format(name)) diff --git a/src/ee/ds/doit.py b/src/ee/ds/doit.py deleted file mode 100644 index f922cf1..0000000 --- a/src/ee/ds/doit.py +++ /dev/null @@ -1,14 +0,0 @@ - - -def uptodate_if_isdir(path): - def do_check(): - return os.path.isdir(path) - return do_check - -def uptodate_if_older_than(dependency, *targets): - def do_check(): - dep_mtime = os.stat(dependency).st_mtime - mtimes = [os.stat(t).st_mtime for t in targets if os.path.isfile(t)] - target_mtime = max(mtimes) if mtimes else 0 - return dep_mtime < target_mtime - return do_check diff --git a/test/doit/test_doit.py b/test/doit/test_doit.py index 969d75c..6f70c6b 100644 --- a/test/doit/test_doit.py +++ b/test/doit/test_doit.py @@ -36,8 +36,8 @@ def exec_task(task): def test_doit(tmpdir, caplog): dsm = DataSetManager(os.path.join(tmpdir, "ee")) - dsm.add_ds("csv", "kicad-footprint", "kicad-footprint-mapping", - path=schematics_dir / "ee" / "kicad-footprint.csv") + dsm.register_ds("csv", "kicad-footprint", "kicad-footprint-mapping", + path=schematics_dir / "ee" / "kicad-footprint.csv") ee.kicad.doit.doit_config.configure(data_set_manager=dsm) ee.kicad.doit.doit_config.change_data_sets_for_task(task_kicad_create_component_data_set, |