ontolutils 0.2.22__tar.gz → 0.3.0__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.2.22 → ontolutils-0.3.0}/PKG-INFO +1 -1
  2. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/classes/thing.py +1 -1
  3. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/utils/qudt_units.py +1 -1
  4. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils.egg-info/PKG-INFO +1 -1
  5. {ontolutils-0.2.22 → ontolutils-0.3.0}/setup.cfg +1 -1
  6. {ontolutils-0.2.22 → ontolutils-0.3.0}/tests/test_classes.py +27 -5
  7. {ontolutils-0.2.22 → ontolutils-0.3.0}/LICENSE +0 -0
  8. {ontolutils-0.2.22 → ontolutils-0.3.0}/README.md +0 -0
  9. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/__init__.py +0 -0
  10. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/_version.py +0 -0
  11. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/cache.py +0 -0
  12. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/classes/__init__.py +0 -0
  13. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/classes/decorator.py +0 -0
  14. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/classes/query_util.py +0 -0
  15. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/classes/typing.py +0 -0
  16. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/classes/utils.py +0 -0
  17. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/__dev.py +0 -0
  18. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/__init__.py +0 -0
  19. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/_iana_utils.py +0 -0
  20. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/codemeta.py +0 -0
  21. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/m4i.py +0 -0
  22. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/obo.py +0 -0
  23. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/qudt_kind.py +0 -0
  24. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/qudt_unit.py +0 -0
  25. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/schema.py +0 -0
  26. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/namespacelib/ssno.py +0 -0
  27. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils/utils/__init__.py +0 -0
  28. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils.egg-info/SOURCES.txt +0 -0
  29. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils.egg-info/dependency_links.txt +0 -0
  30. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils.egg-info/requires.txt +0 -0
  31. {ontolutils-0.2.22 → ontolutils-0.3.0}/ontolutils.egg-info/top_level.txt +0 -0
  32. {ontolutils-0.2.22 → ontolutils-0.3.0}/pyproject.toml +0 -0
  33. {ontolutils-0.2.22 → ontolutils-0.3.0}/setup.py +0 -0
  34. {ontolutils-0.2.22 → ontolutils-0.3.0}/tests/test_decorator.py +0 -0
  35. {ontolutils-0.2.22 → ontolutils-0.3.0}/tests/test_namespaces.py +0 -0
  36. {ontolutils-0.2.22 → ontolutils-0.3.0}/tests/test_query.py +0 -0
  37. {ontolutils-0.2.22 → ontolutils-0.3.0}/tests/test_readme.py +0 -0
  38. {ontolutils-0.2.22 → ontolutils-0.3.0}/tests/test_typing.py +0 -0
  39. {ontolutils-0.2.22 → ontolutils-0.3.0}/tests/test_utils.py +0 -0
  40. {ontolutils-0.2.22 → ontolutils-0.3.0}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.2.22
3
+ Version: 0.3.0
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
@@ -19,7 +19,7 @@ logger = logging.getLogger('ontolutils')
19
19
  EXTRA = 'allow' # or 'forbid' or 'ignore'
20
20
 
21
21
 
22
- class ThingModel(BaseModel, abc.ABC):
22
+ class ThingModel(BaseModel, abc.ABC, validate_assignment=True):
23
23
  """Abstract base model class to be used by model classes used within ontolutils"""
24
24
 
25
25
  model_config = ConfigDict(extra=EXTRA, populate_by_name=True)
@@ -68,7 +68,7 @@ qudt_lookup = {
68
68
  'm**3/s': QUDT_UNIT.M3_PER_SEC,
69
69
  'm**3 s-1': QUDT_UNIT.M3_PER_SEC,
70
70
  'm**3*s-1': QUDT_UNIT.M3_PER_SEC,
71
- 'm**3 s-1': QUDT_UNIT.M3_PER_SEC,
71
+ 'm**3 s**-1': QUDT_UNIT.M3_PER_SEC,
72
72
  # density
73
73
  'kg/m**3': QUDT_UNIT.KiloGM_PER_M3,
74
74
  'kg/m^3': QUDT_UNIT.KiloGM_PER_M3,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.2.22
3
+ Version: 0.3.0
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.2.22
3
+ version = 0.3.0
4
4
  author = Matthias Probst
5
5
  author_email = matthias.probst@kit.edu
6
6
  description = Utility library for the work with ontologies.
@@ -2,10 +2,13 @@ import datetime
2
2
  import json
3
3
  import logging
4
4
  import unittest
5
- from rdflib.plugins.shared.jsonld.context import Context
5
+ from typing import Optional
6
+
6
7
  import pydantic
7
8
  import rdflib
8
- from pydantic import EmailStr, Field
9
+ from pydantic import EmailStr
10
+ from pydantic import field_validator, Field
11
+ from rdflib.plugins.shared.jsonld.context import Context
9
12
 
10
13
  from ontolutils import Thing, urirefs, namespaces, get_urirefs, get_namespaces
11
14
  from ontolutils import set_logging_level
@@ -45,6 +48,13 @@ class TestNamespaces(unittest.TestCase):
45
48
  """
46
49
  name: str = Field(default=None, alias="lastName") # name is synonymous to lastName
47
50
  age: int = None
51
+ special_field: Optional[str] = None
52
+
53
+ @field_validator('special_field', mode="before")
54
+ @classmethod
55
+ def _special_field(cls, value):
56
+ assert value == "special_string", f"Special field must be 'special_string' not {value}"
57
+ return value
48
58
 
49
59
  agent = Agent(name='John Doe', age=23)
50
60
  self.assertEqual(agent.name, 'John Doe')
@@ -59,6 +69,17 @@ class TestNamespaces(unittest.TestCase):
59
69
  self.assertEqual(agent.name, None)
60
70
  self.assertEqual(agent.age, 23)
61
71
 
72
+ # property assignment should fail:
73
+ with self.assertRaises(pydantic.ValidationError):
74
+ agent.age = "invalid"
75
+
76
+ with self.assertRaises(pydantic.ValidationError):
77
+ agent.special_field = "invalid"
78
+ self.assertEqual(agent.special_field, None)
79
+
80
+ agent.special_field = "special_string"
81
+ self.assertEqual(agent.special_field, "special_string")
82
+
62
83
  def test_resolve_iri(self):
63
84
  ret = resolve_iri('foaf:age', context=Context(source={'foaf': 'http://xmlns.com/foaf/0.1/'}))
64
85
  self.assertEqual(ret, 'http://xmlns.com/foaf/0.1/age')
@@ -72,7 +93,8 @@ class TestNamespaces(unittest.TestCase):
72
93
  ret = resolve_iri('label', context=Context(source={'age': 'http://xmlns.com/foaf/0.1/age'}))
73
94
  self.assertEqual(ret, 'http://www.w3.org/2000/01/rdf-schema#label')
74
95
 
75
- ret = resolve_iri('label', context=Context(source={'label': {'@id': 'http://www.w3.org/2000/01/rdf-schema#label'}}))
96
+ ret = resolve_iri('label',
97
+ context=Context(source={'label': {'@id': 'http://www.w3.org/2000/01/rdf-schema#label'}}))
76
98
  self.assertEqual(ret, 'http://www.w3.org/2000/01/rdf-schema#label')
77
99
 
78
100
  ret = resolve_iri('prefix:label', Context(source={}))
@@ -93,6 +115,7 @@ class TestNamespaces(unittest.TestCase):
93
115
  def test_thing_custom_prop(self):
94
116
  """It is helpful to have the properties equal to the urirefs keys,
95
117
  however, this should not be required!"""
118
+
96
119
  @namespaces(foaf='http://xmlns.com/foaf/0.1/',
97
120
  schema='http://www.schema.org/')
98
121
  @urirefs(Affiliation='prov:Affiliation',
@@ -110,7 +133,7 @@ class TestNamespaces(unittest.TestCase):
110
133
  first_name: str = Field(default=None, alias='firstName')
111
134
  lastName: str
112
135
  age: int = None
113
- affiliation: Affiliation=None
136
+ affiliation: Affiliation = None
114
137
 
115
138
  p = Person(first_name='John', lastName='Doe', age=23)
116
139
  person_json = p.model_dump_jsonld(resolve_keys=False)
@@ -341,7 +364,6 @@ class TestNamespaces(unittest.TestCase):
341
364
  self.assertEqual(jsonld_dict['rdfs:label'], 'Person 1')
342
365
  self.assertEqual(jsonld_dict['@type'], 'foaf:Person')
343
366
 
344
-
345
367
  def test_prov(self):
346
368
  @namespaces(prov="https://www.w3.org/ns/prov#",
347
369
  foaf="http://xmlns.com/foaf/0.1/")
File without changes
File without changes
File without changes
File without changes