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.
- {ontolutils-0.4.4 → ontolutils-0.4.6}/PKG-INFO +1 -1
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/query_util.py +13 -1
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/PKG-INFO +1 -1
- {ontolutils-0.4.4 → ontolutils-0.4.6}/setup.cfg +1 -1
- {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_classes.py +42 -1
- {ontolutils-0.4.4 → ontolutils-0.4.6}/LICENSE +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/README.md +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/__init__.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/_version.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/cache.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/__init__.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/decorator.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/thing.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/typing.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/classes/utils.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/__dev.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/__init__.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/_iana_utils.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/codemeta.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/m4i.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/obo.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/qudt_kind.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/qudt_unit.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/schema.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/namespacelib/ssno.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/utils/__init__.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils/utils/qudt_units.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/SOURCES.txt +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/dependency_links.txt +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/requires.txt +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/ontolutils.egg-info/top_level.txt +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/pyproject.toml +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/setup.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_decorator.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_namespaces.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_query.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_readme.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_typing.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_utils.py +0 -0
- {ontolutils-0.4.4 → ontolutils-0.4.6}/tests/test_version.py +0 -0
|
@@ -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
|
-
|
|
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:
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|