From ec429f152cf1d32a86f5783ed87453b42f7ef190 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 20 Aug 2018 23:28:00 +0200 Subject: o Better STM32 setup. --- dodo.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 dodo.py (limited to 'dodo.py') diff --git a/dodo.py b/dodo.py new file mode 100644 index 0000000..1215454 --- /dev/null +++ b/dodo.py @@ -0,0 +1,43 @@ +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) -- cgit v1.2.3