Skip to content

Commit ee0e889

Browse files
benjarobinJPEWdev
authored andcommitted
generate-bindings: allow to use local files
shacl2code needs to download the following URLs during build time: - https://spdx.org/rdf/3.0.1/spdx-model.ttl - https://spdx.org/rdf/3.0.1/spdx-json-serialize-annotations.ttl - https://spdx.org/rdf/3.0.1/spdx-context.jsonld There are a lot of package build tools that do not allow to download a file during the build. So provide a way to use local file: If the environment variable SHACL2CODE_SPDX_DIR is defined, load the SPDX model and SPDX context from the directory specified by this environment variable. Signed-off-by: Benjamin Robin <benjamin.robin@bootlin.com>
1 parent a06d838 commit ee0e889

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

gen/generate-bindings

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@ echo "# Import all versions" > __init__.py
1414
for v in $SPDX_VERSIONS; do
1515
MODNAME="v$(echo "$v" | sed 's/[^a-zA-Z0-9_]/_/g')"
1616

17-
shacl2code generate --input https://spdx.org/rdf/$v/spdx-model.ttl \
18-
--input https://spdx.org/rdf/$v/spdx-json-serialize-annotations.ttl \
19-
--context https://spdx.org/rdf/$v/spdx-context.jsonld \
20-
--license Apache-2.0 \
21-
python \
22-
-o "$MODNAME.py"
17+
if [ -n "${SHACL2CODE_SPDX_DIR}" ] && [ -d "${SHACL2CODE_SPDX_DIR}/$v" ]
18+
then
19+
shacl2code generate --input "file://${SHACL2CODE_SPDX_DIR}/$v/spdx-model.ttl" \
20+
--input "file://${SHACL2CODE_SPDX_DIR}/$v/spdx-json-serialize-annotations.ttl" \
21+
--context-url "file://${SHACL2CODE_SPDX_DIR}/$v/spdx-context.jsonld" https://spdx.org/rdf/$v/spdx-context.jsonld \
22+
--license Apache-2.0 \
23+
python \
24+
-o "$MODNAME.py"
25+
else
26+
shacl2code generate --input https://spdx.org/rdf/$v/spdx-model.ttl \
27+
--input https://spdx.org/rdf/$v/spdx-json-serialize-annotations.ttl \
28+
--context https://spdx.org/rdf/$v/spdx-context.jsonld \
29+
--license Apache-2.0 \
30+
python \
31+
-o "$MODNAME.py"
32+
fi
2333

2434
echo "from . import $MODNAME" >> __init__.py
2535
done

0 commit comments

Comments
 (0)