This tool can be used to convert a JSONLD SHACL model into various code bindings
shacl2code can be installed using pip:
python3 -m pip install shacl2codeshacl2code can generate bindings from either a local file:
shacl2code generate -i model.jsonld python -o out.pyOr from a URL:
shacl2code generate -i https://spdx.github.io/spdx-3-model/model.jsonld python -o out.pyOr from stdin:
cat model.jsonld | shacl2code generate -i - python -o - > out.pyFor more information, run:
shacl2code --helpThe available language bindings can be viewed by running:
shacl2code listDeveloping on shacl2code is best done using a virtual environment. You can
configure one and install shacl2code in editable mode with all necessary
development dependencies by running:
python3 -m venv .venv
. .venv/bin/activate
pip install -e .[dev]shacl2code has a test suite written in pytest. To run it, setup a
virtual environment as shown above, then run:
pytestIn addition to the test results, a test coverage report will also be generated using pytest-cov