shacl2code 0.0.7__tar.gz → 0.0.9__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.
Files changed (55) hide show
  1. {shacl2code-0.0.7 → shacl2code-0.0.9}/PKG-INFO +1 -1
  2. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/lang/templates/jsonschema.j2 +28 -11
  3. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/lang/templates/python.j2 +358 -233
  4. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/model.py +26 -21
  5. shacl2code-0.0.9/src/shacl2code/version.py +1 -0
  6. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/model/test-context.json +4 -0
  7. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/model/test.ttl +42 -1
  8. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/python/roundtrip.json +6 -0
  9. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/expect/jsonschema/test-context.json +225 -75
  10. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/expect/jsonschema/test.json +225 -75
  11. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/expect/python/test-context.py +477 -371
  12. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/expect/python/test.py +474 -343
  13. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/expect/raw/test-context.txt +4 -0
  14. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/expect/raw/test.txt +16 -14
  15. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/test_jsonschema.py +106 -0
  16. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/test_python.py +173 -119
  17. shacl2code-0.0.7/src/shacl2code/version.py +0 -1
  18. {shacl2code-0.0.7 → shacl2code-0.0.9}/.flake8 +0 -0
  19. {shacl2code-0.0.7 → shacl2code-0.0.9}/.github/workflows/coverage-generate.yaml +0 -0
  20. {shacl2code-0.0.7 → shacl2code-0.0.9}/.github/workflows/coverage-report.yaml +0 -0
  21. {shacl2code-0.0.7 → shacl2code-0.0.9}/.github/workflows/publish.yaml +0 -0
  22. {shacl2code-0.0.7 → shacl2code-0.0.9}/.github/workflows/test.yaml +0 -0
  23. {shacl2code-0.0.7 → shacl2code-0.0.9}/.gitignore +0 -0
  24. {shacl2code-0.0.7 → shacl2code-0.0.9}/LICENSE +0 -0
  25. {shacl2code-0.0.7 → shacl2code-0.0.9}/README.md +0 -0
  26. {shacl2code-0.0.7 → shacl2code-0.0.9}/pyproject.toml +0 -0
  27. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/__init__.py +0 -0
  28. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/__main__.py +0 -0
  29. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/context.py +0 -0
  30. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/lang/__init__.py +0 -0
  31. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/lang/common.py +0 -0
  32. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/lang/jinja.py +0 -0
  33. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/lang/jsonschema.py +0 -0
  34. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/lang/lang.py +0 -0
  35. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/lang/python.py +0 -0
  36. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/main.py +0 -0
  37. {shacl2code-0.0.7 → shacl2code-0.0.9}/src/shacl2code/urlcontext.py +0 -0
  38. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/conftest.py +0 -0
  39. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/abort.j2 +0 -0
  40. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/bad-id.j2 +0 -0
  41. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/bad-node-kind.ttl +0 -0
  42. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/bad-pattern-class.ttl +0 -0
  43. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/bad-pattern-integer.ttl +0 -0
  44. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/bad-reference.jsonld +0 -0
  45. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/context-url.j2 +0 -0
  46. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/context.j2 +0 -0
  47. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/missing-range.ttl +0 -0
  48. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/python/links.json +0 -0
  49. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/data/raw.j2 +0 -0
  50. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/expect/make_expect.py +0 -0
  51. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/test_cli.py +0 -0
  52. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/test_common_jinja.py +0 -0
  53. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/test_common_prefix.py +0 -0
  54. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/test_context.py +0 -0
  55. {shacl2code-0.0.7 → shacl2code-0.0.9}/tests/test_model_source.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: shacl2code
3
- Version: 0.0.7
3
+ Version: 0.0.9
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
@@ -60,9 +60,19 @@
60
60
  "{{ varname(class.clsname) }}": {
61
61
  "allOf": [
62
62
  {
63
+ {%- if class.extensible %}
64
+ "unevaluatedProperties": true,
65
+ {%- endif %}
63
66
  "properties": {
64
67
  "{{ class.id_property or "@id" }}": { "$ref": "#/$defs/{{ class.node_kind.split("#")[-1] }}" },
65
- "{{ context.compact("@type") }}": { "const": "{{ context.compact_vocab(class._id) }}" }
68
+ "{{ context.compact("@type") }}": {
69
+ "oneOf": [
70
+ {%- if class.extensible %}
71
+ { "$ref": "#/$defs/IRI" },
72
+ {%- endif %}
73
+ { "const": "{{ context.compact_vocab(class._id) }}" }
74
+ ]
75
+ }
66
76
  }{%- if class.node_kind == SH.IRI %},
67
77
  "required": ["{{ class.id_property or "@id" }}"]
68
78
  {%- endif %}
@@ -71,6 +81,9 @@
71
81
  ]
72
82
  },
73
83
  "{{ varname(class.clsname) }}_derived": {
84
+ {%- if not class.extensible %}
85
+ "unevaluatedProperties": false,
86
+ {%- endif %}
74
87
  {%- set ns = namespace(external_ref=False, local_ref=False, any_ref=False, json_refs=[]) %}
75
88
  {%- for d in get_all_derived(class) + [class._id] %}
76
89
  {%- set ns.json_refs = ns.json_refs + ["#/$defs/" + varname(classes.get(d).clsname)] %}
@@ -80,13 +93,12 @@
80
93
  {%- if ns.json_refs | length == 1 %}
81
94
  "$ref": "{{ ns.json_refs[0] }}",
82
95
  {%- elif ns.json_refs %}
83
- "oneOf": [
96
+ "anyOf": [
84
97
  {%- for r in ns.json_refs %}
85
98
  { "$ref": "{{ r }}" }{% if not loop.last %},{% endif %}
86
99
  {%- endfor %}
87
- ],
100
+ ]
88
101
  {%- endif %}
89
- "unevaluatedProperties": false
90
102
  },
91
103
  "{{ varname(class.clsname) }}_props": {
92
104
  "allOf": [
@@ -213,11 +225,11 @@
213
225
  {%- endfor %}
214
226
  "IRI": {
215
227
  "type": "string",
216
- "pattern": "^(?!_:).*"
228
+ "pattern": "^(?!_:).+:.+"
217
229
  },
218
230
  "BlankNode": {
219
231
  "type": "string",
220
- "pattern": "^_:.*"
232
+ "pattern": "^_:.+"
221
233
  },
222
234
  "BlankNodeOrIRI": {
223
235
  "oneOf": [
@@ -244,17 +256,22 @@
244
256
  "type": "object",
245
257
  "properties": {
246
258
  "{{ context.compact("@type") }}": {
247
- "enum": [
248
- {%- for class in classes %}
249
- "{{ context.compact_vocab(class._id) }}"{% if not loop.last %},{% endif %}
250
- {%- endfor %}
259
+ "oneOf": [
260
+ { "$ref": "#/$defs/IRI" },
261
+ {
262
+ "enum": [
263
+ {%- for class in classes %}
264
+ "{{ context.compact_vocab(class._id) }}"{% if not loop.last %},{% endif %}
265
+ {%- endfor %}
266
+ ]
267
+ }
251
268
  ]
252
269
  }
253
270
  },
254
271
  "required": ["{{ context.compact("@type") }}"]
255
272
  },
256
273
  "AnyClass": {
257
- "oneOf": [
274
+ "anyOf": [
258
275
  {%- for class in classes %}
259
276
  { "$ref": "#/$defs/{{ varname(class.clsname) }}" }{% if not loop.last %},{% endif %}
260
277
  {%- endfor %}