diff options
author | Helmut Grohne <helmut@subdivi.de> | 2021-04-22 17:25:01 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2021-04-22 17:25:01 +0200 |
commit | 762b92c31d29bd371a2cb20a21fedd7f29cccda8 (patch) | |
tree | 66e534daab8b77ff1a649370804a2024053bbc58 /mdbp/common.py | |
parent | de390ea006643985eb89697b442ecf4f9d595ea8 (diff) | |
download | mdbp-762b92c31d29bd371a2cb20a21fedd7f29cccda8.tar.gz |
fix relative path resolution
For .input.dscpath, a relative path is supposed to be relative to the
json file, but it was relative to cwd. For .output.directory, the matter
was unspecified, but should actually work in the same way. Adapt
implementation to documentation and fix the missing specification.
Diffstat (limited to 'mdbp/common.py')
-rw-r--r-- | mdbp/common.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mdbp/common.py b/mdbp/common.py index d0d2f2d..77cbd33 100644 --- a/mdbp/common.py +++ b/mdbp/common.py @@ -37,6 +37,19 @@ def buildjson(filename: str) -> JsonObject: buildobj, json_load( importlib.resources.open_text("mdbp", "build_schema.json"))) + for attrs in (("input", "dscpath"), ("output", "directory")): + obj = buildobj + for attr in attrs[:-1]: + try: + obj = obj[attr] + except KeyError: + break + else: + try: + obj[attrs[-1]] = str(pathlib.Path(filename).parent / + pathlib.Path(obj[attrs[-1]])) + except KeyError: + pass assert isinstance(buildobj, dict) return buildobj |