import glob import shutil from collections import namedtuple from pathlib import Path import stm32 File = namedtuple("File", "xlsx, csv, owl") files = [File(Path(xlsx), Path("stm32/csv/{}.csv".format(xlsx[6:-5])), Path("stm32/owl/{}.owl".format(xlsx[6:-5]))) for xlsx in list(glob.glob("stm32/*.xlsx"))] def make_parent(path): d = path.parent if not d.is_dir(): d.mkdir() def task_stm32_csv(): def action(xlsx, csv): # print("xlsx={}, csv={}".format(xlsx, csv)) make_parent(csv) stm32.xlsx_to_csv(xlsx, csv) for f in files: yield dict( name=f.csv, actions=[(action, [f.xlsx, f.csv])], file_dep=[f.xlsx], targets=[f.csv], clean=True) def task_stm32_owl(): def action(csv, owl): # print("csv={}, owl={}".format(csv, owl)) make_parent(owl) stm32.csv_to_owl(csv, owl) for f in files: yield dict( name=f.owl, actions=[(action, [f.csv, f.owl])], file_dep=[f.csv], targets=[f.owl], clean=True)