ontolutils 0.2.9__tar.gz → 0.2.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 (39) hide show
  1. {ontolutils-0.2.9 → ontolutils-0.2.10}/PKG-INFO +1 -1
  2. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/classes/thing.py +6 -3
  3. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils.egg-info/PKG-INFO +1 -1
  4. {ontolutils-0.2.9 → ontolutils-0.2.10}/setup.cfg +1 -1
  5. {ontolutils-0.2.9 → ontolutils-0.2.10}/tests/test_classes.py +45 -0
  6. {ontolutils-0.2.9 → ontolutils-0.2.10}/LICENSE +0 -0
  7. {ontolutils-0.2.9 → ontolutils-0.2.10}/README.md +0 -0
  8. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/__init__.py +0 -0
  9. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/_version.py +0 -0
  10. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/cache.py +0 -0
  11. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/classes/__init__.py +0 -0
  12. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/classes/decorator.py +0 -0
  13. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/classes/query_util.py +0 -0
  14. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/classes/typing.py +0 -0
  15. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/classes/utils.py +0 -0
  16. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/__dev.py +0 -0
  17. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/__init__.py +0 -0
  18. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/_iana_utils.py +0 -0
  19. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/codemeta.py +0 -0
  20. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/m4i.py +0 -0
  21. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/obo.py +0 -0
  22. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/pivmeta.py +0 -0
  23. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/qudt_kind.py +0 -0
  24. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/qudt_unit.py +0 -0
  25. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/schema.py +0 -0
  26. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils/namespacelib/ssno.py +0 -0
  27. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils.egg-info/SOURCES.txt +0 -0
  28. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils.egg-info/dependency_links.txt +0 -0
  29. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils.egg-info/requires.txt +0 -0
  30. {ontolutils-0.2.9 → ontolutils-0.2.10}/ontolutils.egg-info/top_level.txt +0 -0
  31. {ontolutils-0.2.9 → ontolutils-0.2.10}/pyproject.toml +0 -0
  32. {ontolutils-0.2.9 → ontolutils-0.2.10}/setup.py +0 -0
  33. {ontolutils-0.2.9 → ontolutils-0.2.10}/tests/test_decorator.py +0 -0
  34. {ontolutils-0.2.9 → ontolutils-0.2.10}/tests/test_namespaces.py +0 -0
  35. {ontolutils-0.2.9 → ontolutils-0.2.10}/tests/test_query.py +0 -0
  36. {ontolutils-0.2.9 → ontolutils-0.2.10}/tests/test_readme.py +0 -0
  37. {ontolutils-0.2.9 → ontolutils-0.2.10}/tests/test_typing.py +0 -0
  38. {ontolutils-0.2.9 → ontolutils-0.2.10}/tests/test_utils.py +0 -0
  39. {ontolutils-0.2.9 → ontolutils-0.2.10}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.2.9
3
+ Version: 0.2.10
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
@@ -3,6 +3,7 @@ import json
3
3
  import logging
4
4
  import pathlib
5
5
  import rdflib
6
+ import warnings
6
7
  from datetime import datetime
7
8
  from pydantic import HttpUrl, FileUrl, BaseModel, ConfigDict
8
9
  from typing import Dict, Union, Optional
@@ -162,7 +163,7 @@ class Thing(ThingModel):
162
163
  logger.debug('Initializing RDF graph to dump the Thing to JSON-LD')
163
164
 
164
165
  # lets auto-generate the context
165
- at_context: Dict = NamespaceManager.get(self.__class__, {})
166
+ at_context: Dict = NamespaceManager.get(self.__class__, {}).copy()
166
167
 
167
168
  if context is None:
168
169
  context = {}
@@ -204,6 +205,7 @@ class Thing(ThingModel):
204
205
 
205
206
  uri_ref_manager = URIRefManager.get(obj.__class__, None)
206
207
  at_context.update(NamespaceManager.get(obj.__class__, {}))
208
+
207
209
  if uri_ref_manager is None:
208
210
  return obj
209
211
 
@@ -381,8 +383,9 @@ class Thing(ThingModel):
381
383
  from . import query
382
384
  if data is not None and isinstance(data, str):
383
385
  if 'http://schema.org/' in data:
384
- print(
385
- 'Replacing http with https in the JSON-LD data. This is a workaround for the schema.org inconsistency.')
386
+ warnings.warn('Replacing http with https in the JSON-LD data. '
387
+ 'This is a workaround for the schema.org inconsistency.',
388
+ UserWarning)
386
389
  data = data.replace('http://schema.org/', 'https://schema.org/')
387
390
  return query(cls, source=source, data=data, limit=limit, context=context)
388
391
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.2.9
3
+ Version: 0.2.10
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.9
3
+ version = 0.2.10
4
4
  author = Matthias Probst
5
5
  author_email = matthias.probst@kit.edu
6
6
  description = Utility library for the work with ontologies.
@@ -178,6 +178,51 @@ class TestNamespaces(unittest.TestCase):
178
178
  'https://git.rwth-aachen.de/nfdi4ing/metadata4ing/metadata4ing/-/raw/master/m4i_context.jsonld'
179
179
  )
180
180
 
181
+ def test_model_dump_jsonld_and_load_with_import(self):
182
+ @namespaces(foaf="http://xmlns.com/foaf/0.1/")
183
+ @urirefs(Agent='foaf:Agent',
184
+ mbox='foaf:mbox')
185
+ class Agent(Thing):
186
+ """Pydantic Model for http://xmlns.com/foaf/0.1/Agent
187
+ Parameters
188
+ ----------
189
+ mbox: EmailStr = None
190
+ Email address (foaf:mbox)
191
+ """
192
+ mbox: EmailStr = None
193
+
194
+ agent = Agent(
195
+ label='Agent 1',
196
+ mbox='my@email.com'
197
+ )
198
+ ns = agent.namespaces
199
+ jsonld_string = agent.model_dump_jsonld(
200
+ context={
201
+ "@import": 'https://raw.githubusercontent.com/matthiasprobst/pivmeta/main/pivmeta_context.jsonld'
202
+ }
203
+ )
204
+ self.assertDictEqual(agent.namespaces, ns)
205
+ self.assertTrue('@import' in json.loads(jsonld_string)['@context'])
206
+ loaded_agent = Agent.from_jsonld(data=jsonld_string, limit=1)
207
+ self.assertDictEqual(loaded_agent.namespaces, ns)
208
+ self.assertEqual(loaded_agent.mbox, agent.mbox)
209
+
210
+ def test_schema_http(self):
211
+ @namespaces(foaf="http://xmlns.com/foaf/0.1/",
212
+ schema="https://schema.org/")
213
+ @urirefs(Agent='foaf:Agent',
214
+ name='schema:name')
215
+ class Agent(Thing):
216
+ name: str
217
+
218
+ agent = Agent(name='John Doe')
219
+ self.assertEqual(agent.name, 'John Doe')
220
+ agent_jsonld = agent.model_dump_jsonld()
221
+ print(agent_jsonld.replace('https://schema', 'http://schema'))
222
+ with self.assertWarns(UserWarning):
223
+ agent.from_jsonld(data=agent_jsonld.replace('https://schema', 'http://schema'),
224
+ limit=1)
225
+
181
226
  def test_model_dump_jsonld_nested(self):
182
227
  @namespaces(foaf="http://xmlns.com/foaf/0.1/")
183
228
  @urirefs(Agent='foaf:Agent',
File without changes
File without changes
File without changes
File without changes