Commit 12ac2ddb authored by Eric Duminil's avatar Eric Duminil
Browse files

Modifying run_simstadt structure a bit

parent 358ed818
......@@ -64,7 +64,7 @@ SCRIPT_DIR = Path(__file__).parent
SIMSTADT_GLOB = 'Desktop/SimStadt_0.*/'
REPO_PATH = SCRIPT_DIR.parent.parent / 'simstadt' / 'TestRepository'
REPO_PATH = Path.home() / 'git' / 'simstadt' / 'TestRepository'
PROJECT_NAME = 'Gruenbuehl'
WORKFLOW_FOLDERS = ['a.step', 'b.step']
CITYGMLS = ['Gruenbuehl_LOD2_ALKIS_1010.gml', 'Gruenbuehl_LOD2_ALKIS_1010_2buildings.gml']
......@@ -72,12 +72,11 @@ CITYGMLS = ['Gruenbuehl_LOD2_ALKIS_1010.gml', 'Gruenbuehl_LOD2_ALKIS_1010_2build
##############################################
PROJECT_PATH = REPO_PATH / f'{PROJECT_NAME}.proj'
PARAMS = 'params.xml'
# TODO: write tests
def find_simstadt(simstadt_glob):
def find_simstadt(simstadt_glob: str) -> Path:
try:
found = next(Path.home().glob(simstadt_glob))
logging.info("# SimStadt found in %s\n", found)
......@@ -86,7 +85,7 @@ def find_simstadt(simstadt_glob):
sys.exit(f"Sorry, no SimStadt installation could be found in {simstadt_glob}")
def check_paths(repo_path, workflow_path):
def check_paths(repo_path: Path, workflow_path: Path):
if not repo_path.exists():
sys.exit(f"Sorry, no Repository could be found in {repo_path}")
......@@ -103,6 +102,9 @@ def check_paths(repo_path, workflow_path):
def prepare_workflow(workflow_path, citygmls):
if isinstance(citygmls, str):
citygmls = [citygmls]
tree = et.parse(workflow_path / PARAMS)
root = tree.getroot()
......@@ -173,10 +175,10 @@ def compare_written_files(repo_path, before, after):
logging.info("\n")
def run_workflow(simstadt_path, workflow_folder, citygmls):
workflow_path = PROJECT_PATH / workflow_folder
def run_workflow(simstadt_path: Path, workflow_path: Path, citygmls: list[str]):
repo_path = workflow_path.parent.parent
check_paths(REPO_PATH, workflow_path)
check_paths(repo_path, workflow_path)
name = prepare_workflow(workflow_path, citygmls)
......@@ -184,15 +186,16 @@ def run_workflow(simstadt_path, workflow_folder, citygmls):
run_simstadt(simstadt_path, workflow_path, name)
after = get_all_files(workflow_path)
compare_written_files(REPO_PATH, before, after)
compare_written_files(repo_path, before, after)
def main(glob, workflows, citygmls):
def main(glob: str, repo: Path, project_name: str, workflows: list[str], citygmls: list[str]):
simstadt_path = find_simstadt(glob)
project_path = repo / f'{project_name}.proj'
for workflow_folder in workflows:
run_workflow(simstadt_path, workflow_folder, citygmls)
run_workflow(simstadt_path, project_path / workflow_folder, citygmls)
if __name__ == '__main__':
main(SIMSTADT_GLOB, WORKFLOW_FOLDERS, CITYGMLS)
main(SIMSTADT_GLOB, REPO_PATH, PROJECT_NAME, WORKFLOW_FOLDERS, CITYGMLS)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment