shacl2code 0.0.16__tar.gz → 0.0.17__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {shacl2code-0.0.16 → shacl2code-0.0.17}/PKG-INFO +3 -2
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/__init__.py +1 -0
- shacl2code-0.0.17/src/shacl2code/lang/golang.py +279 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/classes.go.j2 +325 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/decode.go.j2 +334 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/encode.go.j2 +73 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/errorhandler.go.j2 +12 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/errors.go.j2 +44 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/extensible.go.j2 +47 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/linkstate.go.j2 +13 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/listproperty.go.j2 +112 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/optional.go.j2 +34 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/path.go.j2 +30 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/property.go.j2 +99 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/ref.go.j2 +91 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/reflistproperty.go.j2 +43 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/refproperty.go.j2 +90 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/shaclobject.go.j2 +128 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/shaclobjectset.go.j2 +308 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/shacltype.go.j2 +178 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/util.go.j2 +27 -0
- shacl2code-0.0.17/src/shacl2code/lang/templates/golang/validator.go.j2 +108 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/python.j2 +28 -4
- shacl2code-0.0.17/src/shacl2code/version.py +1 -0
- shacl2code-0.0.17/testfixtures/testfixtures/__init__.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17/testfixtures}/testfixtures/jsonvalidation.py +77 -15
- shacl2code-0.0.17/testfixtures/testfixtures/timetests.py +193 -0
- shacl2code-0.0.17/testfixtures/testfixtures/utils.py +18 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/conftest.py +1 -1
- {shacl2code-0.0.16/tests/data/python → shacl2code-0.0.17/tests/data}/links.json +13 -3
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/model/test-context.json +4 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/model/test.ttl +10 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/roundtrip.json +4 -1
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/Doxyfile +1 -1
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/Makefile +3 -3
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/test-context-validate.cpp +2 -2
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/test-context.cpp +7 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/test-context.hpp +10 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/test-context.pc +1 -1
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/Doxyfile +1 -1
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/Makefile +3 -3
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/test-validate.cpp +2 -2
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/test.cpp +7 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/test.hpp +8 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/test.pc +1 -1
- shacl2code-0.0.17/tests/expect/golang/context/test-context/classes.go +3893 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/decode.go +332 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/encode.go +71 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/errorhandler.go +9 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/errors.go +42 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/extensible.go +45 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/linkstate.go +10 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/listproperty.go +110 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/optional.go +32 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/path.go +28 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/property.go +97 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/ref.go +89 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/reflistproperty.go +40 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/refproperty.go +87 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/shaclobject.go +125 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/shaclobjectset.go +297 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/shacltype.go +175 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/util.go +24 -0
- shacl2code-0.0.17/tests/expect/golang/context/test-context/validator.go +105 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/classes.go +3864 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/decode.go +332 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/encode.go +71 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/errorhandler.go +9 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/errors.go +42 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/extensible.go +45 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/linkstate.go +10 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/listproperty.go +110 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/optional.go +32 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/path.go +28 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/property.go +97 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/ref.go +89 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/reflistproperty.go +40 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/refproperty.go +87 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/shaclobject.go +125 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/shaclobjectset.go +297 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/shacltype.go +175 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/util.go +24 -0
- shacl2code-0.0.17/tests/expect/golang/nocontext/test/validator.go +105 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/jsonschema/context/test-context.json +6 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/jsonschema/nocontext/test.json +6 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/make_expect.py +6 -1
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/python/context/test-context.py +35 -4
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/python/nocontext/test.py +34 -4
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/raw/nocontext/test.txt +1 -1
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/test_cpp.py +1 -1
- shacl2code-0.0.17/tests/test_golang.py +1182 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/test_jsonschema.py +1 -1
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/test_python.py +34 -216
- shacl2code-0.0.16/src/shacl2code/version.py +0 -1
- {shacl2code-0.0.16 → shacl2code-0.0.17}/.flake8 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/.github/workflows/coverage-generate.yaml +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/.github/workflows/coverage-report.yaml +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/.github/workflows/publish.yaml +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/.github/workflows/test.yaml +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/.gitignore +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/LICENSE +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/README.md +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/pyproject.toml +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/__init__.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/__main__.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/context.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/common.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/cpp.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/jinja.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/jsonschema.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/lang.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/python.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/sources/cpp/json.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/Doxyfile.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/Makefile.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/api.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/datetime.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/datetime.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/decode.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/decode.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/encode.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/encode.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/errorhandler.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/errorhandler.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/exceptions.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/extensible.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/extensible.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/header.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/jsonld-header.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/jsonld-source.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/link.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/link.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/namedindividual.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/namedindividual.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/object.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/object.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/objectpath.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/objectpath.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/objectset.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/objectset.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/pkgconfig.pc.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/prop.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/property.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/property.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/propertyvalue.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/propertyvalue.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/ref.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/refproperty.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/refproperty.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/source.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/type.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/type.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/util.cpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/util.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/validate.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/cpp/walk.hpp.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/lang/templates/jsonschema.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/main.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/model.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/src/shacl2code/urlcontext.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17/testfixtures}/testfixtures/httpserver.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/abort.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/bad-id.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/bad-node-kind.ttl +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/bad-pattern-class.ttl +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/bad-pattern-integer.ttl +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/bad-prop-type.ttl +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/bad-reference.jsonld +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/context-url.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/context.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/missing-range.ttl +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/python/bad-object-type-inline.json +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/python/bad-object-type-ref-after.json +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/python/bad-object-type-ref-before.json +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/data/raw.j2 +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/api.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/datetime.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/datetime.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/decode.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/decode.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/encode.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/encode.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/errorhandler.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/errorhandler.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/exceptions.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/extensible.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/extensible.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/link.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/link.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/namedindividual.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/namedindividual.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/object.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/object.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/objectpath.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/objectpath.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/objectset.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/objectset.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/prop.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/property.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/property.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/propertyvalue.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/propertyvalue.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/ref.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/refproperty.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/refproperty.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/test-context-jsonld.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/test-context-jsonld.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/type.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/type.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/util.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/util.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/context/walk.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/api.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/datetime.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/datetime.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/decode.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/decode.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/encode.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/encode.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/errorhandler.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/errorhandler.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/exceptions.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/extensible.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/extensible.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/link.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/link.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/namedindividual.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/namedindividual.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/object.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/object.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/objectpath.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/objectpath.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/objectset.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/objectset.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/prop.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/property.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/property.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/propertyvalue.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/propertyvalue.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/ref.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/refproperty.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/refproperty.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/test-jsonld.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/test-jsonld.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/type.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/type.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/util.cpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/util.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/cpp/nocontext/walk.hpp +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/expect/raw/context/test-context.txt +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/test_cli.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/test_common_jinja.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/test_common_prefix.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/test_context.py +0 -0
- {shacl2code-0.0.16 → shacl2code-0.0.17}/tests/test_model_source.py +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: shacl2code
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.17
|
|
4
4
|
Summary: Convert SHACL model file to code bindings
|
|
5
5
|
Project-URL: Homepage, https://github.com/JPEWdev/shacl2code
|
|
6
6
|
Project-URL: Repository, https://github.com/JPEWdev/shacl2code.git
|
|
7
7
|
Project-URL: Issues, https://github.com/JPEWdev/shacl2code/issues
|
|
8
8
|
Author-email: Joshua Watt <JPEWhacker@gmail.com>
|
|
9
|
+
License-File: LICENSE
|
|
9
10
|
Classifier: Development Status :: 4 - Beta
|
|
10
11
|
Classifier: Intended Audience :: Developers
|
|
11
12
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024 Joshua Watt
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
5
|
+
|
|
6
|
+
from .common import JinjaTemplateRender
|
|
7
|
+
from .lang import language, TEMPLATE_DIR
|
|
8
|
+
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
|
|
13
|
+
GO_KEYWORDS = (
|
|
14
|
+
"break",
|
|
15
|
+
"default",
|
|
16
|
+
"func",
|
|
17
|
+
"interface",
|
|
18
|
+
"select",
|
|
19
|
+
"case",
|
|
20
|
+
"defer",
|
|
21
|
+
"go",
|
|
22
|
+
"map",
|
|
23
|
+
"struct",
|
|
24
|
+
"chan",
|
|
25
|
+
"else",
|
|
26
|
+
"goto",
|
|
27
|
+
"package",
|
|
28
|
+
"switch",
|
|
29
|
+
"const",
|
|
30
|
+
"fallthrough",
|
|
31
|
+
"if",
|
|
32
|
+
"range",
|
|
33
|
+
"type",
|
|
34
|
+
"continue",
|
|
35
|
+
"for",
|
|
36
|
+
"import",
|
|
37
|
+
"return",
|
|
38
|
+
"var",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def varname(*name, public=True):
|
|
43
|
+
new_name = []
|
|
44
|
+
for n in name:
|
|
45
|
+
for s in re.split(r"[^a-zA-Z0-9]+", n):
|
|
46
|
+
if not s:
|
|
47
|
+
continue
|
|
48
|
+
new_name.append(s)
|
|
49
|
+
if public:
|
|
50
|
+
new_name = [s[0].upper() + s[1:] for s in new_name]
|
|
51
|
+
else:
|
|
52
|
+
new_name = [new_name[0][0].lower() + new_name[0][1:]] + [
|
|
53
|
+
s[0].upper() + s[1:] for s in new_name[1:]
|
|
54
|
+
]
|
|
55
|
+
new_name = "".join(new_name)
|
|
56
|
+
if new_name in GO_KEYWORDS:
|
|
57
|
+
new_name = new_name + "_"
|
|
58
|
+
return new_name
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def struct_name(cls):
|
|
62
|
+
return varname(*cls.clsname) + "Object"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def interface_name(cls):
|
|
66
|
+
return varname(*cls.clsname)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def class_type_var(cls):
|
|
70
|
+
return varname(*cls.clsname, public=False) + "Type"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def prop_name(prop):
|
|
74
|
+
return varname(prop.varname, public=False)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def prop_is_list(prop):
|
|
78
|
+
return prop.max_count is None or prop.max_count != 1
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def prop_go_type(prop, classes):
|
|
82
|
+
if prop.enum_values:
|
|
83
|
+
return "string"
|
|
84
|
+
|
|
85
|
+
if prop.class_id:
|
|
86
|
+
intf = interface_name(classes.get(prop.class_id))
|
|
87
|
+
return f"Ref[{intf}]"
|
|
88
|
+
|
|
89
|
+
if prop.datatype == "http://www.w3.org/2001/XMLSchema#string":
|
|
90
|
+
return "string"
|
|
91
|
+
|
|
92
|
+
if prop.datatype == "http://www.w3.org/2001/XMLSchema#anyURI":
|
|
93
|
+
return "string"
|
|
94
|
+
|
|
95
|
+
if prop.datatype == "http://www.w3.org/2001/XMLSchema#integer":
|
|
96
|
+
return "int"
|
|
97
|
+
|
|
98
|
+
if prop.datatype == "http://www.w3.org/2001/XMLSchema#positiveInteger":
|
|
99
|
+
return "int"
|
|
100
|
+
|
|
101
|
+
if prop.datatype == "http://www.w3.org/2001/XMLSchema#nonNegativeInteger":
|
|
102
|
+
return "int"
|
|
103
|
+
|
|
104
|
+
if prop.datatype == "http://www.w3.org/2001/XMLSchema#boolean":
|
|
105
|
+
return "bool"
|
|
106
|
+
|
|
107
|
+
if prop.datatype == "http://www.w3.org/2001/XMLSchema#decimal":
|
|
108
|
+
return "float64"
|
|
109
|
+
|
|
110
|
+
if prop.datatype == "http://www.w3.org/2001/XMLSchema#dateTime":
|
|
111
|
+
return "time.Time"
|
|
112
|
+
|
|
113
|
+
if prop.datatype == "http://www.w3.org/2001/XMLSchema#dateTimeStamp":
|
|
114
|
+
return "time.Time"
|
|
115
|
+
|
|
116
|
+
raise Exception("Unknown data type " + prop.datatype) # pragma: no cover
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def prop_ctx_name(cls, prop):
|
|
120
|
+
return varname(*cls.clsname, public=False) + varname(prop.varname) + "Context"
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def prop_decode_func(cls, prop, classes):
|
|
124
|
+
if prop.enum_values:
|
|
125
|
+
func = "DecodeIRI"
|
|
126
|
+
|
|
127
|
+
elif prop.class_id:
|
|
128
|
+
func = "Decode" + interface_name(classes.get(prop.class_id))
|
|
129
|
+
|
|
130
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#string":
|
|
131
|
+
func = "DecodeString"
|
|
132
|
+
|
|
133
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#anyURI":
|
|
134
|
+
func = "DecodeString"
|
|
135
|
+
|
|
136
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#integer":
|
|
137
|
+
func = "DecodeInteger"
|
|
138
|
+
|
|
139
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#positiveInteger":
|
|
140
|
+
func = "DecodeInteger"
|
|
141
|
+
|
|
142
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#nonNegativeInteger":
|
|
143
|
+
func = "DecodeInteger"
|
|
144
|
+
|
|
145
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#boolean":
|
|
146
|
+
func = "DecodeBoolean"
|
|
147
|
+
|
|
148
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#decimal":
|
|
149
|
+
func = "DecodeFloat"
|
|
150
|
+
|
|
151
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#dateTime":
|
|
152
|
+
func = "DecodeDateTime"
|
|
153
|
+
|
|
154
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#dateTimeStamp":
|
|
155
|
+
func = "DecodeDateTimeStamp"
|
|
156
|
+
|
|
157
|
+
else:
|
|
158
|
+
raise Exception("Unknown data type " + prop.datatype) # pragma: no cover
|
|
159
|
+
|
|
160
|
+
if prop_is_list(prop):
|
|
161
|
+
return f"DecodeList[{prop_go_type(prop, classes)}](value, path, {prop_ctx_name(cls, prop)}, {func}, obj.{varname(prop.varname)}())"
|
|
162
|
+
|
|
163
|
+
return f"{func}(value, path, {prop_ctx_name(cls, prop)}, obj.{varname(prop.varname)}())"
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def prop_encode_func(cls, prop, classes):
|
|
167
|
+
if prop.enum_values:
|
|
168
|
+
func = "EncodeIRI"
|
|
169
|
+
|
|
170
|
+
elif prop.class_id:
|
|
171
|
+
func = "EncodeRef[" + interface_name(classes.get(prop.class_id)) + "]"
|
|
172
|
+
|
|
173
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#string":
|
|
174
|
+
func = "EncodeString"
|
|
175
|
+
|
|
176
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#anyURI":
|
|
177
|
+
func = "EncodeString"
|
|
178
|
+
|
|
179
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#integer":
|
|
180
|
+
func = "EncodeInteger"
|
|
181
|
+
|
|
182
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#positiveInteger":
|
|
183
|
+
func = "EncodeInteger"
|
|
184
|
+
|
|
185
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#nonNegativeInteger":
|
|
186
|
+
func = "EncodeInteger"
|
|
187
|
+
|
|
188
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#boolean":
|
|
189
|
+
func = "EncodeBoolean"
|
|
190
|
+
|
|
191
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#decimal":
|
|
192
|
+
func = "EncodeFloat"
|
|
193
|
+
|
|
194
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#dateTime":
|
|
195
|
+
func = "EncodeDateTime"
|
|
196
|
+
|
|
197
|
+
elif prop.datatype == "http://www.w3.org/2001/XMLSchema#dateTimeStamp":
|
|
198
|
+
func = "EncodeDateTime"
|
|
199
|
+
|
|
200
|
+
else:
|
|
201
|
+
raise Exception("Unknown data type " + prop.datatype) # pragma: no cover
|
|
202
|
+
|
|
203
|
+
if prop_is_list(prop):
|
|
204
|
+
return f'EncodeList[{prop_go_type(prop, classes)}](self.{prop_name(prop)}.Get(), path.PushPath("{prop_name(prop)}"), {prop_ctx_name(cls, prop)}, state, {func})'
|
|
205
|
+
|
|
206
|
+
return f'{func}(self.{prop_name(prop)}.Get(), path.PushPath("{prop_name(prop)}"), {prop_ctx_name(cls, prop)}, state)'
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@language("golang")
|
|
210
|
+
class GoLangRender(JinjaTemplateRender):
|
|
211
|
+
HELP = "Go Schema"
|
|
212
|
+
|
|
213
|
+
FILES = (
|
|
214
|
+
"classes.go",
|
|
215
|
+
"decode.go",
|
|
216
|
+
"encode.go",
|
|
217
|
+
"errorhandler.go",
|
|
218
|
+
"errors.go",
|
|
219
|
+
"extensible.go",
|
|
220
|
+
"linkstate.go",
|
|
221
|
+
"listproperty.go",
|
|
222
|
+
"optional.go",
|
|
223
|
+
"path.go",
|
|
224
|
+
"property.go",
|
|
225
|
+
"ref.go",
|
|
226
|
+
"reflistproperty.go",
|
|
227
|
+
"refproperty.go",
|
|
228
|
+
"shaclobject.go",
|
|
229
|
+
"shaclobjectset.go",
|
|
230
|
+
"shacltype.go",
|
|
231
|
+
"util.go",
|
|
232
|
+
"validator.go",
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
def __init__(self, args):
|
|
236
|
+
super().__init__()
|
|
237
|
+
self.__output = args.output
|
|
238
|
+
self.__render_args = {
|
|
239
|
+
"package": args.package,
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@classmethod
|
|
243
|
+
def get_arguments(cls, parser):
|
|
244
|
+
parser.add_argument(
|
|
245
|
+
"-p",
|
|
246
|
+
"--package",
|
|
247
|
+
help="Go Package Name",
|
|
248
|
+
default="model",
|
|
249
|
+
)
|
|
250
|
+
parser.add_argument(
|
|
251
|
+
"--output",
|
|
252
|
+
"-o",
|
|
253
|
+
type=Path,
|
|
254
|
+
help="Output directory",
|
|
255
|
+
required=True,
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
def get_outputs(self):
|
|
259
|
+
t = TEMPLATE_DIR / "golang"
|
|
260
|
+
|
|
261
|
+
for s in self.FILES:
|
|
262
|
+
yield self.__output / s, t / (s + ".j2"), {}
|
|
263
|
+
|
|
264
|
+
def get_extra_env(self):
|
|
265
|
+
return {
|
|
266
|
+
"varname": varname,
|
|
267
|
+
"struct_name": struct_name,
|
|
268
|
+
"interface_name": interface_name,
|
|
269
|
+
"class_type_var": class_type_var,
|
|
270
|
+
"prop_name": prop_name,
|
|
271
|
+
"prop_is_list": prop_is_list,
|
|
272
|
+
"prop_go_type": prop_go_type,
|
|
273
|
+
"prop_ctx_name": prop_ctx_name,
|
|
274
|
+
"prop_decode_func": prop_decode_func,
|
|
275
|
+
"prop_encode_func": prop_encode_func,
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
def get_additional_render_args(self):
|
|
279
|
+
return self.__render_args
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
//
|
|
2
|
+
//{#
|
|
3
|
+
vim: ft=go
|
|
4
|
+
#}
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
package {{ package }}
|
|
8
|
+
|
|
9
|
+
import (
|
|
10
|
+
"time"
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
{% for class in classes %}
|
|
14
|
+
{%- for l in class.comment.splitlines() %}
|
|
15
|
+
{{ ("// " + l).rstrip() }}
|
|
16
|
+
{% endfor -%}
|
|
17
|
+
{% set is_public = not class.is_abstract or class.is_extensible -%}
|
|
18
|
+
type {{ struct_name(class) }} struct {
|
|
19
|
+
{%- if class.parent_ids %}
|
|
20
|
+
{%- for p in class.parent_ids %}
|
|
21
|
+
{{ struct_name(classes.get(p)) }}
|
|
22
|
+
{%- endfor %}
|
|
23
|
+
{%- else %}
|
|
24
|
+
SHACLObjectBase
|
|
25
|
+
{%- endif %}
|
|
26
|
+
{%- if class.is_extensible %}
|
|
27
|
+
SHACLExtensibleBase
|
|
28
|
+
{%- endif %}
|
|
29
|
+
{% for prop in class.properties %}
|
|
30
|
+
{%- for l in prop.comment.splitlines() %}
|
|
31
|
+
{{ ("// " + l).rstrip() }}
|
|
32
|
+
{%- endfor %}
|
|
33
|
+
{%- if not prop.enum_values and prop.class_id %}
|
|
34
|
+
{{ prop_name(prop) }} Ref{% if prop_is_list(prop) %}List{% endif %}Property[{{ interface_name(classes.get(prop.class_id)) }}]
|
|
35
|
+
{%- else %}
|
|
36
|
+
{{ prop_name(prop) }} {% if prop_is_list(prop) %}List{% endif %}Property[{{ prop_go_type(prop, classes) }}]
|
|
37
|
+
{%- endif %}
|
|
38
|
+
{%- endfor %}
|
|
39
|
+
}
|
|
40
|
+
{% for member in class.named_individuals %}
|
|
41
|
+
{%- for l in member.comment.splitlines() %}
|
|
42
|
+
{{ ("// " + l).rstrip() }}
|
|
43
|
+
{% endfor -%}
|
|
44
|
+
const {{ varname(*class.clsname) }}{{ varname(member.varname) }} = "{{ member._id }}"
|
|
45
|
+
{%- endfor %}
|
|
46
|
+
|
|
47
|
+
type {{ struct_name(class) }}Type struct {
|
|
48
|
+
SHACLTypeBase
|
|
49
|
+
}
|
|
50
|
+
var {{ class_type_var(class) }} {{ struct_name(class) }}Type
|
|
51
|
+
|
|
52
|
+
{%- for prop in class.properties %}
|
|
53
|
+
var {{ prop_ctx_name(class, prop) }} = map[string]string{
|
|
54
|
+
{%- if prop.enum_values %}
|
|
55
|
+
{%- for value in prop.enum_values %}
|
|
56
|
+
"{{ value }}": "{{ context.compact_vocab(value, prop.path) }}",
|
|
57
|
+
{%- endfor %}
|
|
58
|
+
{%- elif prop.class_id %}
|
|
59
|
+
{%- for value in get_all_named_individuals(classes.get(prop.class_id)) %}
|
|
60
|
+
{%- if context.compact_vocab(value, prop.path) != value %}
|
|
61
|
+
"{{ value }}": "{{ context.compact_vocab(value, prop.path) }}",
|
|
62
|
+
{%- endif %}
|
|
63
|
+
{%- endfor -%}
|
|
64
|
+
{%- endif -%}
|
|
65
|
+
}
|
|
66
|
+
{%- endfor %}
|
|
67
|
+
|
|
68
|
+
func Decode{{ interface_name(class) }} (data any, path Path, context map[string]string, check DecodeCheckType) (Ref[{{ interface_name(class) }}], error) {
|
|
69
|
+
return DecodeRef[{{ interface_name(class) }}](data, path, context, {{ class_type_var(class) }}, check)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
func (self {{ struct_name(class) }}Type) DecodeProperty(o SHACLObject, name string, value interface{}, path Path) (bool, error) {
|
|
73
|
+
obj := o.({{ interface_name(class) }})
|
|
74
|
+
_ = obj
|
|
75
|
+
switch name {
|
|
76
|
+
{%- for prop in class.properties %}
|
|
77
|
+
case "{{ prop.path }}"{% if context.compact_vocab(prop.path) != prop.path %}, "{{ context.compact_vocab(prop.path) }}"{% endif %}:
|
|
78
|
+
val, err := {{ prop_decode_func(class, prop, classes) }}
|
|
79
|
+
if err != nil {
|
|
80
|
+
return false, err
|
|
81
|
+
}
|
|
82
|
+
err = obj.{{ varname(prop.varname) }}().Set(val)
|
|
83
|
+
if err != nil {
|
|
84
|
+
return false, err
|
|
85
|
+
}
|
|
86
|
+
return true, nil
|
|
87
|
+
{%- endfor %}
|
|
88
|
+
default:
|
|
89
|
+
found, err := self.SHACLTypeBase.DecodeProperty(o, name, value, path)
|
|
90
|
+
if err != nil || found {
|
|
91
|
+
return found, err
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return false, nil
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
func (self {{ struct_name(class) }}Type) Create() SHACLObject {
|
|
99
|
+
return Construct{{ struct_name(class) }}(&{{ struct_name(class) }}{}, self)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
func Construct{{ struct_name(class) }}(o *{{ struct_name(class) }}, typ SHACLType) *{{ struct_name(class) }} {
|
|
103
|
+
{%- if class.parent_ids %}
|
|
104
|
+
{%- for p in class.parent_ids %}
|
|
105
|
+
Construct{{ struct_name(classes.get(p)) }}(&o.{{ struct_name(classes.get(p)) }}, typ)
|
|
106
|
+
{%- endfor %}
|
|
107
|
+
{%- else %}
|
|
108
|
+
ConstructSHACLObjectBase(&o.SHACLObjectBase, typ)
|
|
109
|
+
{%- endif %}
|
|
110
|
+
{%- for prop in class.properties %}
|
|
111
|
+
{
|
|
112
|
+
validators := []Validator[{{ prop_go_type(prop, classes) }}]{}
|
|
113
|
+
decodeValidators := []Validator[any]{}
|
|
114
|
+
{%- if prop.enum_values %}
|
|
115
|
+
validators = append(validators,
|
|
116
|
+
EnumValidator{[]string{
|
|
117
|
+
{%- for e in prop.enum_values %}
|
|
118
|
+
"{{e}}",
|
|
119
|
+
{%- endfor %}
|
|
120
|
+
}})
|
|
121
|
+
{%- elif prop.datatype == "http://www.w3.org/2001/XMLSchema#positiveInteger" %}
|
|
122
|
+
validators = append(validators, IntegerMinValidator{1})
|
|
123
|
+
{%- elif prop.datatype == "http://www.w3.org/2001/XMLSchema#nonNegativeInteger" %}
|
|
124
|
+
validators = append(validators, IntegerMinValidator{0})
|
|
125
|
+
{%- endif %}
|
|
126
|
+
{%- if prop.pattern %}
|
|
127
|
+
validators = append(validators, RegexValidator[{{ prop_go_type(prop, classes) }}]{`{{ prop.pattern }}`})
|
|
128
|
+
decodeValidators = append(decodeValidators, RegexValidator[any]{`{{ prop.pattern }}`})
|
|
129
|
+
{%- endif %}
|
|
130
|
+
{%- if not prop.enum_values and prop.class_id %}
|
|
131
|
+
o.{{ prop_name(prop) }} = NewRef{% if prop_is_list(prop) %}List{% endif %}Property[{{ interface_name(classes.get(prop.class_id)) }}]("{{ prop_name(prop) }}", validators, decodeValidators)
|
|
132
|
+
{%- else %}
|
|
133
|
+
o.{{ prop_name(prop) }} = New{% if prop_is_list(prop) %}List{% endif %}Property[{{ prop_go_type(prop, classes) }}]("{{ prop_name(prop) }}", validators, decodeValidators)
|
|
134
|
+
{%- endif %}
|
|
135
|
+
}
|
|
136
|
+
{%- endfor %}
|
|
137
|
+
return o
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type {{ interface_name(class) }} interface {
|
|
141
|
+
{%- if class.parent_ids %}
|
|
142
|
+
{%- for p in class.parent_ids %}
|
|
143
|
+
{{ interface_name(classes.get(p)) }}
|
|
144
|
+
{%- endfor %}
|
|
145
|
+
{%- else %}
|
|
146
|
+
SHACLObject
|
|
147
|
+
{%- endif %}
|
|
148
|
+
{%- for prop in class.properties %}
|
|
149
|
+
{%- if prop_is_list(prop) %}
|
|
150
|
+
{{ varname(prop.varname) }}() ListPropertyInterface[{{ prop_go_type(prop, classes) }}]
|
|
151
|
+
{%- elif not prop.enum_values and prop.class_id %}
|
|
152
|
+
{{ varname(prop.varname) }}() RefPropertyInterface[{{ interface_name(classes.get(prop.class_id)) }}]
|
|
153
|
+
{%- else %}
|
|
154
|
+
{{ varname(prop.varname) }}() PropertyInterface[{{ prop_go_type(prop, classes) }}]
|
|
155
|
+
{%- endif %}
|
|
156
|
+
{%- endfor %}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
{% if not class.is_abstract %}
|
|
160
|
+
func Make{{ varname(*class.clsname) }}() {{ interface_name(class) }} {
|
|
161
|
+
return Construct{{ struct_name(class) }}(&{{ struct_name(class) }}{}, {{ class_type_var(class) }})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
func Make{{ varname(*class.clsname) }}Ref() Ref[{{ interface_name(class) }}] {
|
|
165
|
+
o := Make{{ varname(*class.clsname) }}()
|
|
166
|
+
return MakeObjectRef[{{ interface_name(class) }}](o)
|
|
167
|
+
}
|
|
168
|
+
{%- endif %}
|
|
169
|
+
|
|
170
|
+
func (self *{{ struct_name(class) }}) Validate(path Path, handler ErrorHandler) bool {
|
|
171
|
+
var valid bool = true
|
|
172
|
+
{%- if class.parent_ids %}
|
|
173
|
+
{%- for p in class.parent_ids %}
|
|
174
|
+
if ! self.{{ struct_name(classes.get(p)) }}.Validate(path, handler) {
|
|
175
|
+
valid = false
|
|
176
|
+
}
|
|
177
|
+
{%- endfor %}
|
|
178
|
+
{%- else %}
|
|
179
|
+
if ! self.SHACLObjectBase.Validate(path, handler) {
|
|
180
|
+
valid = false
|
|
181
|
+
}
|
|
182
|
+
{%- endif %}
|
|
183
|
+
{%- for prop in class.properties %}
|
|
184
|
+
{
|
|
185
|
+
prop_path := path.PushPath("{{ prop_name(prop) }}")
|
|
186
|
+
if ! self.{{ prop_name(prop) }}.Check(prop_path, handler) {
|
|
187
|
+
valid = false
|
|
188
|
+
}
|
|
189
|
+
{%- if prop_is_list(prop) %}
|
|
190
|
+
{%- if not prop.min_count is none %}
|
|
191
|
+
if len(self.{{ prop_name(prop) }}.Get()) < {{ prop.min_count }} {
|
|
192
|
+
if handler != nil {
|
|
193
|
+
handler.HandleError(&ValidationError{
|
|
194
|
+
"{{ prop_name(prop) }}",
|
|
195
|
+
"Too few elements. Minimum of {{ prop.min_count }} required"},
|
|
196
|
+
prop_path)
|
|
197
|
+
}
|
|
198
|
+
valid = false
|
|
199
|
+
}
|
|
200
|
+
{%- endif %}
|
|
201
|
+
{%- if not prop.max_count is none %}
|
|
202
|
+
if len(self.{{ prop_name(prop) }}.Get()) > {{ prop.max_count }} {
|
|
203
|
+
if handler != nil {
|
|
204
|
+
handler.HandleError(&ValidationError{
|
|
205
|
+
"{{ prop_name(prop) }}",
|
|
206
|
+
"Too many elements. Maximum of {{ prop.max_count }} allowed"},
|
|
207
|
+
prop_path)
|
|
208
|
+
}
|
|
209
|
+
valid = false
|
|
210
|
+
}
|
|
211
|
+
{%- endif %}
|
|
212
|
+
{%- else %}
|
|
213
|
+
{%- if not prop.min_count is none and prop.min_count > 0 %}
|
|
214
|
+
if ! self.{{ prop_name(prop) }}.IsSet() {
|
|
215
|
+
if handler != nil {
|
|
216
|
+
handler.HandleError(&ValidationError{"{{ prop_name(prop) }}", "Value is required"}, prop_path)
|
|
217
|
+
}
|
|
218
|
+
valid = false
|
|
219
|
+
}
|
|
220
|
+
{%- endif %}
|
|
221
|
+
{%- endif %}
|
|
222
|
+
}
|
|
223
|
+
{%- endfor %}
|
|
224
|
+
return valid
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
func (self *{{ struct_name(class) }}) Walk(path Path, visit Visit) {
|
|
228
|
+
{%- if class.parent_ids %}
|
|
229
|
+
{%- for p in class.parent_ids %}
|
|
230
|
+
self.{{ struct_name(classes.get(p)) }}.Walk(path, visit)
|
|
231
|
+
{%- endfor %}
|
|
232
|
+
{%- else %}
|
|
233
|
+
self.SHACLObjectBase.Walk(path, visit)
|
|
234
|
+
{%- endif %}
|
|
235
|
+
{%- for prop in class.properties %}
|
|
236
|
+
self.{{ prop_name(prop) }}.Walk(path, visit)
|
|
237
|
+
{%- endfor %}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
func (self *{{ struct_name(class) }}) Link(state *LinkState) error {
|
|
241
|
+
{%- if class.parent_ids %}
|
|
242
|
+
{%- for p in class.parent_ids %}
|
|
243
|
+
if err := self.{{ struct_name(classes.get(p)) }}.Link(state); err != nil {
|
|
244
|
+
return err
|
|
245
|
+
}
|
|
246
|
+
{%- endfor %}
|
|
247
|
+
{%- else %}
|
|
248
|
+
if err := self.SHACLObjectBase.Link(state); err != nil {
|
|
249
|
+
return err
|
|
250
|
+
}
|
|
251
|
+
{%- endif %}
|
|
252
|
+
{%- for prop in class.properties %}
|
|
253
|
+
if err := self.{{ prop_name(prop) }}.Link(state); err != nil {
|
|
254
|
+
return err
|
|
255
|
+
}
|
|
256
|
+
{%- endfor %}
|
|
257
|
+
return nil
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
{% for prop in class.properties %}
|
|
261
|
+
{%- if prop_is_list(prop) %}
|
|
262
|
+
func (self *{{ struct_name(class) }}) {{ varname(prop.varname) }}() ListPropertyInterface[{{ prop_go_type(prop, classes) }}] { return &self.{{ prop_name(prop) }} }
|
|
263
|
+
{%- elif not prop.enum_values and prop.class_id %}
|
|
264
|
+
func (self *{{ struct_name(class) }}) {{ varname(prop.varname) }}() RefPropertyInterface[{{ interface_name(classes.get(prop.class_id)) }}] { return &self.{{ prop_name(prop) }} }
|
|
265
|
+
{%- else %}
|
|
266
|
+
func (self *{{ struct_name(class) }}) {{ varname(prop.varname) }}() PropertyInterface[{{ prop_go_type(prop, classes) }}] { return &self.{{ prop_name(prop) }} }
|
|
267
|
+
{%- endif %}
|
|
268
|
+
{%- endfor %}
|
|
269
|
+
|
|
270
|
+
func (self *{{ struct_name(class) }}) EncodeProperties(data map[string]interface{}, path Path, state *EncodeState) error {
|
|
271
|
+
{%- if class.parent_ids %}
|
|
272
|
+
{%- for p in class.parent_ids %}
|
|
273
|
+
if err := self.{{ struct_name(classes.get(p)) }}.EncodeProperties(data, path, state); err != nil {
|
|
274
|
+
return err
|
|
275
|
+
}
|
|
276
|
+
{%- endfor %}
|
|
277
|
+
{%- else %}
|
|
278
|
+
if err := self.SHACLObjectBase.EncodeProperties(data, path, state); err != nil {
|
|
279
|
+
return err
|
|
280
|
+
}
|
|
281
|
+
{%- endif %}
|
|
282
|
+
{%- for prop in class.properties %}
|
|
283
|
+
if self.{{ prop_name(prop) }}.IsSet() {
|
|
284
|
+
val, err := {{ prop_encode_func(class, prop, classes) }}
|
|
285
|
+
if err != nil {
|
|
286
|
+
return err
|
|
287
|
+
}
|
|
288
|
+
data["{{ context.compact_vocab(prop.path) }}"] = val
|
|
289
|
+
}
|
|
290
|
+
{%- endfor %}
|
|
291
|
+
{%- if class.is_extensible %}
|
|
292
|
+
self.SHACLExtensibleBase.EncodeExtProperties(data, path)
|
|
293
|
+
{%- endif %}
|
|
294
|
+
return nil
|
|
295
|
+
}
|
|
296
|
+
{% endfor %}
|
|
297
|
+
|
|
298
|
+
func init() {
|
|
299
|
+
objectTypes = make(map[string] SHACLType)
|
|
300
|
+
|
|
301
|
+
{%- for class in classes %}
|
|
302
|
+
{{ class_type_var(class) }} = {{ struct_name(class) }}Type{
|
|
303
|
+
SHACLTypeBase: SHACLTypeBase{
|
|
304
|
+
typeIRI: "{{ class._id }}",
|
|
305
|
+
{%- if context.compact_iri(class._id) != class._id %}
|
|
306
|
+
compactTypeIRI: NewOptional[string]("{{ context.compact_iri(class._id) }}"),
|
|
307
|
+
{%- endif %}
|
|
308
|
+
isAbstract: {% if class.is_abstract %}true{% else %}false{% endif %},
|
|
309
|
+
nodeKind: NewOptional[int](NodeKind{{ class.node_kind.split('#')[-1] }}),
|
|
310
|
+
{%- if class.is_extensible %}
|
|
311
|
+
isExtensible: NewOptional[bool](true),
|
|
312
|
+
{%- endif %}
|
|
313
|
+
{%- if class.id_property %}
|
|
314
|
+
idAlias: NewOptional[string]("{{ class.id_property }}"),
|
|
315
|
+
{%- endif %}
|
|
316
|
+
parentIRIs: []string{ {%- for p in class.parent_ids %}
|
|
317
|
+
"{{ p }}",
|
|
318
|
+
{%- endfor %}
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
}
|
|
322
|
+
RegisterType({{ class_type_var(class) }})
|
|
323
|
+
{%- endfor %}
|
|
324
|
+
}
|
|
325
|
+
|