ontolutils 0.4.4__tar.gz → 0.4.6__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 (40) hide show
  1. {ontolutils-0.4.4 → ontolutils-0.4.6}/PKG-INFO +1 -1
  2. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/query_util.py +13 -1
  3. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/PKG-INFO +1 -1
  4. {ontolutils-0.4.4 → ontolutils-0.4.6}/setup.cfg +1 -1
  5. {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_classes.py +42 -1
  6. {ontolutils-0.4.4 → ontolutils-0.4.6}/LICENSE +0 -0
  7. {ontolutils-0.4.4 → ontolutils-0.4.6}/README.md +0 -0
  8. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/__init__.py +0 -0
  9. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/_version.py +0 -0
  10. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/cache.py +0 -0
  11. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/__init__.py +0 -0
  12. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/decorator.py +0 -0
  13. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/thing.py +0 -0
  14. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/typing.py +0 -0
  15. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/utils.py +0 -0
  16. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/__dev.py +0 -0
  17. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/__init__.py +0 -0
  18. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/_iana_utils.py +0 -0
  19. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/codemeta.py +0 -0
  20. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/m4i.py +0 -0
  21. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/obo.py +0 -0
  22. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/qudt_kind.py +0 -0
  23. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/qudt_unit.py +0 -0
  24. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/schema.py +0 -0
  25. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/ssno.py +0 -0
  26. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/utils/__init__.py +0 -0
  27. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/utils/qudt_units.py +0 -0
  28. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/SOURCES.txt +0 -0
  29. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/dependency_links.txt +0 -0
  30. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/requires.txt +0 -0
  31. {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/top_level.txt +0 -0
  32. {ontolutils-0.4.4 → ontolutils-0.4.6}/pyproject.toml +0 -0
  33. {ontolutils-0.4.4 → ontolutils-0.4.6}/setup.py +0 -0
  34. {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_decorator.py +0 -0
  35. {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_namespaces.py +0 -0
  36. {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_query.py +0 -0
  37. {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_readme.py +0 -0
  38. {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_typing.py +0 -0
  39. {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_utils.py +0 -0
  40. {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.4.4
3
+ Version: 0.4.6
4
4
  Summary: Utility library for the work with ontologies.
5
5
  Home-page: https://github.com/matthiasprobst/ontology-utils
6
6
  Author: Matthias Probst
@@ -60,7 +60,19 @@ WHERE {
60
60
  if isinstance(o, rdflib.BNode):
61
61
  logger.debug(f'"{o}" is a blank node. Need to find children of it...')
62
62
  _, key = split_URIRef(p)
63
- sub_data[key] = process_object(_id, p, o, graph, add_type)
63
+ if key in sub_data:
64
+ if isinstance(sub_data[key], list):
65
+ sub_data[key].append(process_object(_id, p, o, graph, add_type))
66
+ else:
67
+ sub_data[key] = [sub_data[key], process_object(_id, p, o, graph, add_type)]
68
+ else:
69
+ sub_data[key] = process_object(_id, p, o, graph, add_type)
70
+ elif str(o).startswith('http'):
71
+ # it might be a IRI which is defined inside the JSON-LD:
72
+ _sub_data = process_object(_id, p, o, graph, add_type)
73
+ if _sub_data:
74
+ _, key = split_URIRef(p)
75
+ sub_data[key] = _sub_data
64
76
  else:
65
77
  logger.debug(f'dont know what to do with {p} and {o}')
66
78
  if predicate in sub_data:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.4.4
3
+ Version: 0.4.6
4
4
  Summary: Utility library for the work with ontologies.
5
5
  Home-page: https://github.com/matthiasprobst/ontology-utils
6
6
  Author: Matthias Probst
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = ontolutils
3
- version = 0.4.4
3
+ version = 0.4.6
4
4
  author = Matthias Probst
5
5
  author_email = matthias.probst@kit.edu
6
6
  description = Utility library for the work with ontologies.
@@ -169,6 +169,48 @@ class TestNamespaces(unittest.TestCase):
169
169
  with self.assertRaises(AttributeError): # height is not defined!
170
170
  p183_from_jsonld.height
171
171
 
172
+ def test_from_jsonld_for_nested_objects(self):
173
+
174
+ @namespaces(prov='http://www.w3.org/ns/prov#')
175
+ @urirefs(A='prov:A',
176
+ name='prov:name')
177
+ class A(Thing):
178
+ name: str = None
179
+
180
+ @namespaces(prov='http://www.w3.org/ns/prov#')
181
+ @urirefs(B='prov:B',
182
+ a='prov:a')
183
+ class B(Thing):
184
+ a: A = None
185
+
186
+ @namespaces(prov='http://www.w3.org/ns/prov#')
187
+ @urirefs(C='prov:C',
188
+ b='prov:b')
189
+ class C(Thing):
190
+ b: B = None
191
+
192
+ @namespaces(prov='http://www.w3.org/ns/prov#')
193
+ @urirefs(D='prov:D',
194
+ c='prov:c')
195
+ class D(Thing):
196
+ c: C = None
197
+
198
+ aj = A(name="myname").model_dump_jsonld()
199
+ an = A.from_jsonld(data=aj, limit=1)
200
+ self.assertEqual("myname", an.name)
201
+
202
+ bj = B(a=(A(name="myname"))).model_dump_jsonld()
203
+ bn = B.from_jsonld(data=bj, limit=1)
204
+ self.assertEqual("myname", bn.a.name)
205
+
206
+ cj = C(b=B(a=(A(name="myname")))).model_dump_jsonld()
207
+ cn = C.from_jsonld(data=cj, limit=1)
208
+ self.assertEqual("myname", cn.b.a.name)
209
+
210
+ dj = D(c=C(b=B(a=(A(name="myname"))))).model_dump_jsonld()
211
+ dn = D.from_jsonld(data=dj, limit=1)
212
+ self.assertEqual("myname", dn.c.b.a.name)
213
+
172
214
  def test_sort_classes(self):
173
215
  thing1 = Thing(label='Thing 1', id='_:1')
174
216
  thing2 = Thing(label='Thing 2', id='_:2')
@@ -413,7 +455,6 @@ class TestNamespaces(unittest.TestCase):
413
455
  "foaf:firstName": "John",
414
456
  "foaf:lastName": "Doe"
415
457
  }
416
- print(p.model_dump_jsonld())
417
458
 
418
459
  self.assertDictEqual(json.loads(p.model_dump_jsonld()),
419
460
  jsonld)
File without changes
File without changes
File without changes
File without changes