From 5a6ab34565fa3d783337a68e07e3500361c8fcf5 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 4 Mar 2019 00:06:32 +0100 Subject: o PartDB: don't die if the directory exist *and* is empty. Ninja creates empty parent directories. o PartDB: escape some path names. o new comamnd: "ninja". Generates a build.ninja from a sch. Not done! --- src/ee/part/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/ee/part') diff --git a/src/ee/part/__init__.py b/src/ee/part/__init__.py index cf60dd5..d4d99ac 100644 --- a/src/ee/part/__init__.py +++ b/src/ee/part/__init__.py @@ -81,7 +81,9 @@ def save_db(dir_path: Path, db: PartDb): idx_path = dir_path / "index.xml" if not idx_path.is_file(): - raise EeException("The given db directory exists, but does not look like a part db dir") + # Ninja creates the parent directories out the output.. + if len(list(dir_path.iterdir())) > 0: + raise EeException("The given db directory exists, but does not look like a part db dir") for p in dir_path.iterdir(): if not p.is_file(): @@ -100,7 +102,7 @@ def save_db(dir_path: Path, db: PartDb): for part in parts: id_ = part.id - path = dir_path / "{}.xml".format(id_) + path = dir_path / "{}.xml".format(id_.replace("/", "_")) with path.open("w") as f: part.export(outfile=f, level=0, name_=find_root_tag(part)) -- cgit v1.2.3