diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b852e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +al2.egg-info/ +__pycache__ +dist/ + +*.swp diff --git a/al2/__init__.py b/al2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/al2/batch.py b/al2/batch.py new file mode 100644 index 0000000..50968c1 --- /dev/null +++ b/al2/batch.py @@ -0,0 +1,38 @@ +import json +import pathlib as pl + +def load(batch_file): + batch_file = pl.Path(batch_file).resolve() + + with open(batch_file, "r") as bfile: + batch_obj = json.loads(bfile.read()) + + batch_obj["base_path"] = batch_file.parent + + return __load_batch_obj(batch_obj) + + +def __load_batch_obj(batch_obj): + paths = [] + + instance_dir = None + + if "dir" in batch_obj: + instance_dir = pl.Path(batch_obj["dir"]) + + if not instance_dir.is_absolute(): + instance_dir = pl.Path(batch_obj["base_path"], instance_dir) + else: + instance_dir = batch_obj["base_path"] + + if "instances" in batch_obj: + for instance in batch_obj["instances"]: + paths.append(pl.Path(instance_dir, instance)) + + if "batches" in batch_obj: + for batch in batch_obj["batches"]: + batch["base_path"] = instance_dir + + paths.extend(__load_batch_obj(batch)) + + return paths diff --git a/setup.py b/setup.py index e69de29..b111c8c 100644 --- a/setup.py +++ b/setup.py @@ -0,0 +1,7 @@ +from setuptools import setup, find_packages + +setup(name="al2", + version="0.1.0", + packages=["al2"], + author="Tom Krueger", + python_requires=">=3")