Browse Source

bare batch load functionality

master
Tom Krüger 4 years ago
parent
commit
86d4176fcc
4 changed files with 50 additions and 0 deletions
  1. +5
    -0
      .gitignore
  2. +0
    -0
      al2/__init__.py
  3. +38
    -0
      al2/batch.py
  4. +7
    -0
      setup.py

+ 5
- 0
.gitignore View File

@ -0,0 +1,5 @@
al2.egg-info/
__pycache__
dist/
*.swp

+ 0
- 0
al2/__init__.py View File


+ 38
- 0
al2/batch.py View File

@ -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

+ 7
- 0
setup.py View File

@ -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")

Loading…
Cancel
Save