summaryrefslogtreecommitdiff
path: root/mdbp
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2021-04-22 17:25:01 +0200
committerHelmut Grohne <helmut@subdivi.de>2021-04-22 17:25:01 +0200
commit762b92c31d29bd371a2cb20a21fedd7f29cccda8 (patch)
tree66e534daab8b77ff1a649370804a2024053bbc58 /mdbp
parentde390ea006643985eb89697b442ecf4f9d595ea8 (diff)
downloadmdbp-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')
-rw-r--r--mdbp/build_schema.json2
-rw-r--r--mdbp/common.py13
2 files changed, 14 insertions, 1 deletions
diff --git a/mdbp/build_schema.json b/mdbp/build_schema.json
index b8d905d..baa38ef 100644
--- a/mdbp/build_schema.json
+++ b/mdbp/build_schema.json
@@ -121,7 +121,7 @@
"properties": {
"directory": {
"type": "string",
- "description": "target directory to place output artifacts"
+ "description": "target directory to place output artifacts, can be specified relative to the location of this json file"
}
}
}
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