import inspect import os import pathlib from inspect import Parameter import ee.digikey.doit import ee.kicad.doit from ee.digikey.doit import * from ee.ds import DataSetManager from ee.kicad.doit import * logger = logging.getLogger(__name__) file_dir = pathlib.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(pathlib.Path(tmpdir) / "ee") 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, lambda ds: ds + ["kicad-footprint"]) ee.kicad.doit.init(sch=schematics_dir / "schematic-1.sch", kicad_pcb=schematics_dir / "schematic-1.kicad_pcb", ) ee.digikey.doit.doit_config.configure(data_set_manager=dsm) exec_task(task_kicad_sch_to_data_set()) exec_task(task_kicad_pcb_to_data_set()) exec_task(task_kicad_create_component_data_set()) exec_task(task_digikey_resolve_schematic_components()) exec_task(task_digikey_fetch_full_part_facts())