import inspect import os import os.path import logging from pathlib import Path from ee.ds import DataSetManager from inspect import Parameter import ee.kicad.doit from ee.kicad.doit import * logger = logging.getLogger(__name__) file_dir = Path(__file__).parent schematics_dir = file_dir / "schematics" def exec_task(task): targets = task["targets"] for a in task["actions"]: if isinstance(a, str): cmd = a % dict(targets=" ".join(targets)) ret = os.system(cmd) assert (ret == 0) else: parameters = {} for p in inspect.signature(a).parameters.values(): if p.kind == Parameter.POSITIONAL_OR_KEYWORD and p.name == "targets": parameters["targets"] = targets a(**parameters) # noinspection SpellCheckingInspection 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") ee.kicad.doit.change_data_sets_for_task(task_kicad_create_component_data_set, lambda ds: ds + ["kicad-footprint"]) ee.kicad.doit.init(data_set_manager=dsm, sch=schematics_dir / "schematic-1.sch", kicad_pcb=schematics_dir / "schematic-1.kicad_pcb",) exec_task(task_kicad_sch_to_data_set()) exec_task(task_kicad_pcb_to_data_set()) exec_task(task_kicad_create_component_data_set())