ontolutils 0.6.2__tar.gz → 0.6.3__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.6.2 → ontolutils-0.6.3}/PKG-INFO +1 -1
  2. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/classes/thing.py +6 -1
  3. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils.egg-info/PKG-INFO +1 -1
  4. {ontolutils-0.6.2 → ontolutils-0.6.3}/setup.cfg +1 -1
  5. {ontolutils-0.6.2 → ontolutils-0.6.3}/tests/test_classes.py +41 -2
  6. {ontolutils-0.6.2 → ontolutils-0.6.3}/LICENSE +0 -0
  7. {ontolutils-0.6.2 → ontolutils-0.6.3}/README.md +0 -0
  8. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/__init__.py +0 -0
  9. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/_version.py +0 -0
  10. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/cache.py +0 -0
  11. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/classes/__init__.py +0 -0
  12. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/classes/decorator.py +0 -0
  13. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/classes/query_util.py +0 -0
  14. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/classes/typing.py +0 -0
  15. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/classes/utils.py +0 -0
  16. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/config.py +0 -0
  17. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/namespacelib/__dev.py +0 -0
  18. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/namespacelib/__init__.py +0 -0
  19. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/namespacelib/_iana_utils.py +0 -0
  20. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/namespacelib/codemeta.py +0 -0
  21. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/namespacelib/m4i.py +0 -0
  22. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/namespacelib/obo.py +0 -0
  23. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/namespacelib/qudt_kind.py +0 -0
  24. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/namespacelib/qudt_unit.py +0 -0
  25. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/namespacelib/schema.py +0 -0
  26. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/utils/__init__.py +0 -0
  27. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils/utils/qudt_units.py +0 -0
  28. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils.egg-info/SOURCES.txt +0 -0
  29. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils.egg-info/dependency_links.txt +0 -0
  30. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils.egg-info/requires.txt +0 -0
  31. {ontolutils-0.6.2 → ontolutils-0.6.3}/ontolutils.egg-info/top_level.txt +0 -0
  32. {ontolutils-0.6.2 → ontolutils-0.6.3}/pyproject.toml +0 -0
  33. {ontolutils-0.6.2 → ontolutils-0.6.3}/setup.py +0 -0
  34. {ontolutils-0.6.2 → ontolutils-0.6.3}/tests/test_decorator.py +0 -0
  35. {ontolutils-0.6.2 → ontolutils-0.6.3}/tests/test_namespaces.py +0 -0
  36. {ontolutils-0.6.2 → ontolutils-0.6.3}/tests/test_query.py +0 -0
  37. {ontolutils-0.6.2 → ontolutils-0.6.3}/tests/test_readme.py +0 -0
  38. {ontolutils-0.6.2 → ontolutils-0.6.3}/tests/test_typing.py +0 -0
  39. {ontolutils-0.6.2 → ontolutils-0.6.3}/tests/test_utils.py +0 -0
  40. {ontolutils-0.6.2 → ontolutils-0.6.3}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.6.2
3
+ Version: 0.6.3
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
@@ -291,7 +291,12 @@ class Thing(ThingModel):
291
291
  "@context": at_context,
292
292
  **serialization
293
293
  }
294
- for field_name, field_value in self.__class__.model_json_schema()["properties"].items():
294
+
295
+ properties = self.__class__.model_json_schema().get("properties", {})
296
+ if not properties:
297
+ properties = self.__class__.model_json_schema().get("items", {}).get(self.__class__.__name__, {}).get("properties", {})
298
+
299
+ for field_name, field_value in properties.items():
295
300
  _use_as_id = field_value.get("use_as_id", None)
296
301
  if _use_as_id is not None:
297
302
  _id = getattr(self, field_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.6.2
3
+ Version: 0.6.3
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.6.2
3
+ version = 0.6.3
4
4
  author = Matthias Probst
5
5
  author_email = matthias.probst@kit.edu
6
6
  description = Utility library for the work with ontologies.
@@ -2,6 +2,7 @@ import datetime
2
2
  import json
3
3
  import logging
4
4
  import unittest
5
+ from cProfile import label
5
6
  from typing import Optional
6
7
 
7
8
  import pydantic
@@ -429,14 +430,13 @@ class TestNamespaces(unittest.TestCase):
429
430
  self.assertEqual(Agent.iri('mbox'), 'http://xmlns.com/foaf/0.1/mbox')
430
431
  self.assertEqual(Agent.iri('mbox', compact=True), 'foaf:mbox')
431
432
 
432
- def test_person(self):
433
+ def test_use_as_id(self):
433
434
  @namespaces(prov="http://www.w3.org/ns/prov#",
434
435
  foaf="http://xmlns.com/foaf/0.1/",
435
436
  m4i="http://w3id.org/nfdi4ing/metadata4ing#"
436
437
  )
437
438
  @urirefs(Person='prov:Person',
438
439
  firstName='foaf:firstName',
439
- # lastName=FOAF.lastName,
440
440
  lastName='foaf:lastName',
441
441
  orcidId='m4i:orcidId',
442
442
  mbox='foaf:mbox')
@@ -469,6 +469,45 @@ class TestNamespaces(unittest.TestCase):
469
469
  self.assertDictEqual(json.loads(p.model_dump_jsonld()),
470
470
  jsonld)
471
471
 
472
+ def test_use_as_id_V2(self):
473
+
474
+ @namespaces(schema="https://schema.org/",
475
+ foaf="http://xmlns.com/foaf/0.1/",
476
+ )
477
+ @urirefs(Orga='prov:Organization',
478
+ name="schema:name",
479
+ identifier="schema:identifier",
480
+ mbox='foaf:mbox')
481
+ class Orga(Thing):
482
+ identifier: str = Field(default=None, alias="identifier", json_schema_extra={'use_as_id': True})
483
+ name: str = Field(default=None, alias="name")
484
+ mbox: EmailStr = None
485
+
486
+ @namespaces(prov="http://www.w3.org/ns/prov#",
487
+ foaf="http://xmlns.com/foaf/0.1/",
488
+ m4i="http://w3id.org/nfdi4ing/metadata4ing#"
489
+ )
490
+ @urirefs(Person='prov:Person',
491
+ firstName='foaf:firstName',
492
+ lastName='foaf:lastName',
493
+ orcidId='m4i:orcidId',
494
+ mbox='foaf:mbox')
495
+ class Person(Thing):
496
+ firstName: str
497
+ lastName: str = None
498
+ mbox: EmailStr = None
499
+ orcidId: str = Field(default=None, alias="orcid_id", json_schema_extra={'use_as_id': True})
500
+ affiliation: Orga = None
501
+
502
+ p = Person(
503
+ id="local:cde4c79c-21f2-4ab7-b01d-28de6e4aade4",
504
+ firstName='John',
505
+ lastName='Doe',
506
+ orcidId='https://orcid.org/0000-0001-8729-0482',
507
+ affiliation=Orga(identifier='123', name='Orga 1')
508
+ )
509
+ print(p.model_dump_jsonld())
510
+
472
511
  def test_update_namespace_and_uri(self):
473
512
  class CustomPerson(Thing):
474
513
  pass
File without changes
File without changes
File without changes
File without changes