shacl2code 0.0.9__tar.gz → 0.0.10__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 (59) hide show
  1. {shacl2code-0.0.9 → shacl2code-0.0.10}/PKG-INFO +1 -1
  2. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/lang/templates/jsonschema.j2 +25 -19
  3. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/lang/templates/python.j2 +466 -160
  4. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/model.py +27 -46
  5. shacl2code-0.0.10/src/shacl2code/version.py +1 -0
  6. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/model/test-context.json +12 -0
  7. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/model/test.ttl +42 -3
  8. shacl2code-0.0.10/tests/data/python/bad-object-type-inline.json +13 -0
  9. shacl2code-0.0.10/tests/data/python/bad-object-type-ref-after.json +14 -0
  10. shacl2code-0.0.10/tests/data/python/bad-object-type-ref-before.json +14 -0
  11. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/expect/jsonschema/test-context.json +220 -51
  12. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/expect/jsonschema/test.json +220 -51
  13. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/expect/python/test-context.py +516 -197
  14. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/expect/python/test.py +514 -188
  15. shacl2code-0.0.10/tests/expect/raw/test.txt +19 -0
  16. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/test_python.py +337 -34
  17. shacl2code-0.0.9/src/shacl2code/version.py +0 -1
  18. shacl2code-0.0.9/tests/expect/raw/test.txt +0 -19
  19. {shacl2code-0.0.9 → shacl2code-0.0.10}/.flake8 +0 -0
  20. {shacl2code-0.0.9 → shacl2code-0.0.10}/.github/workflows/coverage-generate.yaml +0 -0
  21. {shacl2code-0.0.9 → shacl2code-0.0.10}/.github/workflows/coverage-report.yaml +0 -0
  22. {shacl2code-0.0.9 → shacl2code-0.0.10}/.github/workflows/publish.yaml +0 -0
  23. {shacl2code-0.0.9 → shacl2code-0.0.10}/.github/workflows/test.yaml +0 -0
  24. {shacl2code-0.0.9 → shacl2code-0.0.10}/.gitignore +0 -0
  25. {shacl2code-0.0.9 → shacl2code-0.0.10}/LICENSE +0 -0
  26. {shacl2code-0.0.9 → shacl2code-0.0.10}/README.md +0 -0
  27. {shacl2code-0.0.9 → shacl2code-0.0.10}/pyproject.toml +0 -0
  28. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/__init__.py +0 -0
  29. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/__main__.py +0 -0
  30. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/context.py +0 -0
  31. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/lang/__init__.py +0 -0
  32. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/lang/common.py +0 -0
  33. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/lang/jinja.py +0 -0
  34. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/lang/jsonschema.py +0 -0
  35. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/lang/lang.py +0 -0
  36. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/lang/python.py +0 -0
  37. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/main.py +0 -0
  38. {shacl2code-0.0.9 → shacl2code-0.0.10}/src/shacl2code/urlcontext.py +0 -0
  39. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/conftest.py +0 -0
  40. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/abort.j2 +0 -0
  41. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/bad-id.j2 +0 -0
  42. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/bad-node-kind.ttl +0 -0
  43. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/bad-pattern-class.ttl +0 -0
  44. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/bad-pattern-integer.ttl +0 -0
  45. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/bad-reference.jsonld +0 -0
  46. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/context-url.j2 +0 -0
  47. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/context.j2 +0 -0
  48. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/missing-range.ttl +0 -0
  49. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/python/links.json +0 -0
  50. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/python/roundtrip.json +0 -0
  51. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/data/raw.j2 +0 -0
  52. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/expect/make_expect.py +0 -0
  53. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/expect/raw/test-context.txt +1 -1
  54. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/test_cli.py +0 -0
  55. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/test_common_jinja.py +0 -0
  56. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/test_common_prefix.py +0 -0
  57. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/test_context.py +0 -0
  58. {shacl2code-0.0.9 → shacl2code-0.0.10}/tests/test_jsonschema.py +0 -0
  59. {shacl2code-0.0.9 → shacl2code-0.0.10}/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.9
3
+ Version: 0.0.10
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
@@ -36,11 +36,13 @@
36
36
 
37
37
  "oneOf": [
38
38
  {
39
+ "type": "object",
39
40
  "properties": {
40
41
  "@graph": {
41
42
  "description": "Top level container for JSON-LD objects",
42
43
  "type": "array",
43
44
  "items": {
45
+ "type": "object",
44
46
  "$ref": "#/$defs/AnyClass",
45
47
  "unevaluatedProperties": false
46
48
  }
@@ -60,14 +62,15 @@
60
62
  "{{ varname(class.clsname) }}": {
61
63
  "allOf": [
62
64
  {
63
- {%- if class.extensible %}
65
+ "type": "object",
66
+ {%- if class.is_extensible %}
64
67
  "unevaluatedProperties": true,
65
68
  {%- endif %}
66
69
  "properties": {
67
70
  "{{ class.id_property or "@id" }}": { "$ref": "#/$defs/{{ class.node_kind.split("#")[-1] }}" },
68
71
  "{{ context.compact("@type") }}": {
69
72
  "oneOf": [
70
- {%- if class.extensible %}
73
+ {%- if class.is_extensible %}
71
74
  { "$ref": "#/$defs/IRI" },
72
75
  {%- endif %}
73
76
  { "const": "{{ context.compact_vocab(class._id) }}" }
@@ -81,24 +84,26 @@
81
84
  ]
82
85
  },
83
86
  "{{ varname(class.clsname) }}_derived": {
84
- {%- if not class.extensible %}
85
- "unevaluatedProperties": false,
86
- {%- endif %}
87
87
  {%- set ns = namespace(external_ref=False, local_ref=False, any_ref=False, json_refs=[]) %}
88
88
  {%- for d in get_all_derived(class) + [class._id] %}
89
89
  {%- set ns.json_refs = ns.json_refs + ["#/$defs/" + varname(classes.get(d).clsname)] %}
90
90
  {%- endfor %}
91
- {%- set ns.json_refs = ns.json_refs + ["#/$defs/BlankNodeOrIRI"] %}
92
-
93
- {%- if ns.json_refs | length == 1 %}
94
- "$ref": "{{ ns.json_refs[0] }}",
95
- {%- elif ns.json_refs %}
96
91
  "anyOf": [
97
- {%- for r in ns.json_refs %}
98
- { "$ref": "{{ r }}" }{% if not loop.last %},{% endif %}
99
- {%- endfor %}
92
+ {%- if ns.json_refs %}
93
+ {
94
+ "type": "object",
95
+ {%- if not class.is_extensible %}
96
+ "unevaluatedProperties": false,
97
+ {%- endif %}
98
+ "anyOf": [
99
+ {%- for r in ns.json_refs %}
100
+ { "$ref": "{{ r }}" }{% if not loop.last %},{% endif %}
101
+ {%- endfor %}
102
+ ]
103
+ },
104
+ {%- endif %}
105
+ { "$ref": "#/$defs/BlankNodeOrIRI" }
100
106
  ]
101
- {%- endif %}
102
107
  },
103
108
  "{{ varname(class.clsname) }}_props": {
104
109
  "allOf": [
@@ -111,6 +116,7 @@
111
116
  {%- endif %}
112
117
  {%- set required = [] %}
113
118
  {
119
+ "type": "object",
114
120
  "properties": {
115
121
  {%- for prop in class.properties %}
116
122
  {%- if not prop.min_count is none and prop.min_count > 0 %}
@@ -155,14 +161,14 @@
155
161
  },
156
162
  {%- for prop in class.properties %}
157
163
  "prop_{{ varname(class.clsname) }}_{{ varname(prop.varname) }}": {
158
- {%- if prop.class_id %}
159
- "$ref": "#/$defs/{{ varname(classes.get(prop.class_id).clsname) }}_derived"
160
- {%- elif prop.enum_id %}
164
+ {%- if prop.enum_values %}
161
165
  "enum": [
162
- {%- for e in enums.get(prop.enum_id).values %}
163
- "{{ context.compact_vocab(e._id, prop.path) }}"{% if not loop.last %},{% endif %}
166
+ {%- for e in prop.enum_values %}
167
+ "{{ context.compact_vocab(e, prop.path) }}"{% if not loop.last %},{% endif %}
164
168
  {%- endfor %}
165
169
  ]
170
+ {%- elif prop.class_id %}
171
+ "$ref": "#/$defs/{{ varname(classes.get(prop.class_id).clsname) }}_derived"
166
172
  {%- else %}
167
173
  {%- if prop.datatype == "http://www.w3.org/2001/XMLSchema#string" %}
168
174
  {%- if prop.pattern %}