ontolutils 0.2.6__tar.gz → 0.2.8__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.6 → ontolutils-0.2.8}/PKG-INFO +1 -1
  2. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/classes/thing.py +93 -89
  3. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/__dev.py +22 -16
  4. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/pivmeta.py +6 -2
  5. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/qudt_kind.py +1 -1
  6. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/schema.py +1 -1
  7. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils.egg-info/PKG-INFO +1 -1
  8. {ontolutils-0.2.6 → ontolutils-0.2.8}/setup.cfg +1 -1
  9. {ontolutils-0.2.6 → ontolutils-0.2.8}/tests/test_classes.py +48 -51
  10. {ontolutils-0.2.6 → ontolutils-0.2.8}/tests/test_query.py +2 -2
  11. {ontolutils-0.2.6 → ontolutils-0.2.8}/LICENSE +0 -0
  12. {ontolutils-0.2.6 → ontolutils-0.2.8}/README.md +0 -0
  13. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/__init__.py +0 -0
  14. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/_version.py +0 -0
  15. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/cache.py +0 -0
  16. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/classes/__init__.py +0 -0
  17. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/classes/decorator.py +0 -0
  18. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/classes/query_util.py +0 -0
  19. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/classes/typing.py +0 -0
  20. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/classes/utils.py +0 -0
  21. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/__init__.py +0 -0
  22. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/_iana_utils.py +0 -0
  23. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/codemeta.py +0 -0
  24. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/m4i.py +0 -0
  25. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/obo.py +0 -0
  26. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/qudt_unit.py +0 -0
  27. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils/namespacelib/ssno.py +0 -0
  28. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils.egg-info/SOURCES.txt +0 -0
  29. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils.egg-info/dependency_links.txt +0 -0
  30. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils.egg-info/requires.txt +0 -0
  31. {ontolutils-0.2.6 → ontolutils-0.2.8}/ontolutils.egg-info/top_level.txt +0 -0
  32. {ontolutils-0.2.6 → ontolutils-0.2.8}/pyproject.toml +0 -0
  33. {ontolutils-0.2.6 → ontolutils-0.2.8}/setup.py +0 -0
  34. {ontolutils-0.2.6 → ontolutils-0.2.8}/tests/test_decorator.py +0 -0
  35. {ontolutils-0.2.6 → ontolutils-0.2.8}/tests/test_namespaces.py +0 -0
  36. {ontolutils-0.2.6 → ontolutils-0.2.8}/tests/test_readme.py +0 -0
  37. {ontolutils-0.2.6 → ontolutils-0.2.8}/tests/test_typing.py +0 -0
  38. {ontolutils-0.2.6 → ontolutils-0.2.8}/tests/test_utils.py +0 -0
  39. {ontolutils-0.2.6 → ontolutils-0.2.8}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.2.6
3
+ Version: 0.2.8
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
@@ -25,94 +25,6 @@ class ThingModel(BaseModel, abc.ABC):
25
25
  """Returns the HTML representation of the class"""
26
26
 
27
27
 
28
- def serialize_fields(
29
- obj: Union[ThingModel, int, str, float, bool, datetime],
30
- exclude_none: bool = True
31
- ) -> Union[Dict, int, str, float, bool]:
32
- """Serializes the fields of a Thing object into a json-ld
33
- dictionary (without context!). Note, that IDs can automatically be
34
- generated (with a local prefix)
35
-
36
- Parameter
37
- ---------
38
- obj: Union[ThingModel, int, str, float, bool, datetime]
39
- The object to serialize (a subclass of ThingModel). All other types will
40
- be returned as is. One exception is datetime, which will be serialized
41
- to an ISO string.
42
- exclude_none: bool=True
43
- If True, fields with None values will be excluded from the
44
- serialization
45
-
46
- Returns
47
- -------
48
- Union[Dict, int, str, float, bool]
49
- The serialized fields or the object as is
50
- """
51
- if isinstance(obj, (int, str, float, bool)):
52
- return obj
53
- if isinstance(obj, datetime):
54
- return obj.isoformat()
55
-
56
- uri_ref_manager = URIRefManager.get(obj.__class__, None)
57
- if uri_ref_manager is None:
58
- return obj
59
-
60
- try:
61
- if exclude_none:
62
- serialized_fields = {}
63
- for k in obj.model_fields:
64
- value = getattr(obj, k)
65
- if value is not None and k not in ('id', '@id'):
66
- iri = uri_ref_manager[k]
67
- if _is_http_url(iri):
68
- serialized_fields[k] = value
69
- else:
70
- serialized_fields[iri] = value
71
- else:
72
- serialized_fields = {}
73
- for k in obj.model_fields:
74
- value = getattr(obj, k)
75
- if value not in ('id', '@id'):
76
- iri = uri_ref_manager[k]
77
- if _is_http_url(iri):
78
- serialized_fields[k] = value
79
- else:
80
- serialized_fields[iri] = value
81
- except AttributeError as e:
82
- raise AttributeError(f"Could not serialize {obj} ({obj.__class__}). Orig. err: {e}") from e
83
-
84
- if obj.model_config['extra'] == 'allow':
85
- for k, v in obj.model_extra.items():
86
- iri = uri_ref_manager.get(k, k)
87
- if _is_http_url(iri):
88
- serialized_fields[k] = v
89
- else:
90
- serialized_fields[iri] = v
91
-
92
- # datetime
93
- for k, v in serialized_fields.copy().items():
94
- _field = serialized_fields.pop(k)
95
- key = k
96
- if isinstance(v, datetime):
97
- serialized_fields[key] = serialize_fields(v)
98
- elif isinstance(v, Thing):
99
- serialized_fields[key] = serialize_fields(v, exclude_none=exclude_none)
100
- elif isinstance(v, list):
101
- serialized_fields[key] = [serialize_fields(i, exclude_none=exclude_none) for i in v]
102
- else:
103
- serialized_fields[key] = str(v)
104
-
105
- _type = URIRefManager[obj.__class__].get(obj.__class__.__name__, obj.__class__.__name__)
106
-
107
- out = {"@type": _type, **serialized_fields}
108
- # if no ID is given, generate a local one:
109
- if obj.id is not None:
110
- out["@id"] = obj.id
111
- else:
112
- out["@id"] = rdflib.BNode()
113
- return out
114
-
115
-
116
28
  @namespaces(owl='http://www.w3.org/2002/07/owl#',
117
29
  rdfs='http://www.w3.org/2000/01/rdf-schema#')
118
30
  @urirefs(Thing='owl:Thing', label='rdfs:label')
@@ -166,9 +78,101 @@ class Thing(ThingModel):
166
78
 
167
79
  logger.debug(f'The context is "{at_context}".')
168
80
 
81
+ def serialize_fields(
82
+ obj: Union[ThingModel, int, str, float, bool, datetime],
83
+ exclude_none: bool = True
84
+ ) -> Union[Dict, int, str, float, bool]:
85
+ """Serializes the fields of a Thing object into a json-ld
86
+ dictionary (without context!). Note, that IDs can automatically be
87
+ generated (with a local prefix)
88
+
89
+ Parameter
90
+ ---------
91
+ obj: Union[ThingModel, int, str, float, bool, datetime]
92
+ The object to serialize (a subclass of ThingModel). All other types will
93
+ be returned as is. One exception is datetime, which will be serialized
94
+ to an ISO string.
95
+ exclude_none: bool=True
96
+ If True, fields with None values will be excluded from the
97
+ serialization
98
+
99
+ Returns
100
+ -------
101
+ Union[Dict, int, str, float, bool]
102
+ The serialized fields or the object as is
103
+ """
104
+ if isinstance(obj, (int, str, float, bool)):
105
+ return obj
106
+ if isinstance(obj, datetime):
107
+ return obj.isoformat()
108
+
109
+ uri_ref_manager = URIRefManager.get(obj.__class__, None)
110
+ at_context.update(NamespaceManager.get(obj.__class__, {}))
111
+ if uri_ref_manager is None:
112
+ return obj
113
+
114
+ try:
115
+ if exclude_none:
116
+ serialized_fields = {}
117
+ for k in obj.model_dump(exclude_none=True):
118
+ value = getattr(obj, k)
119
+ if value is not None and k not in ('id', '@id'):
120
+ iri = uri_ref_manager.get(k, k)
121
+ if _is_http_url(iri):
122
+ serialized_fields[iri] = value
123
+ if isinstance(value, str): # this turn URLs into base strings
124
+ serialized_fields[iri] = str(value)
125
+ else:
126
+ serialized_fields[iri] = value
127
+ else:
128
+ serialized_fields = {}
129
+ for k in obj.model_dump(exclude_none=True):
130
+ value = getattr(obj, k)
131
+ if value not in ('id', '@id'):
132
+ iri = uri_ref_manager[k]
133
+ if _is_http_url(iri):
134
+ serialized_fields[k] = value
135
+ else:
136
+ serialized_fields[iri] = value
137
+ except AttributeError as e:
138
+ raise AttributeError(f"Could not serialize {obj} ({obj.__class__}). Orig. err: {e}") from e
139
+
140
+ if obj.model_config['extra'] == 'allow':
141
+ for k, v in obj.model_extra.items():
142
+ iri = uri_ref_manager.get(k, k)
143
+ if _is_http_url(iri):
144
+ serialized_fields[k] = v
145
+ else:
146
+ serialized_fields[iri] = v
147
+
148
+ # datetime
149
+ for k, v in serialized_fields.copy().items():
150
+ _field = serialized_fields.pop(k)
151
+ key = k
152
+ if isinstance(v, datetime):
153
+ serialized_fields[key] = serialize_fields(v)
154
+ elif isinstance(v, Thing):
155
+ serialized_fields[key] = serialize_fields(v, exclude_none=exclude_none)
156
+ elif isinstance(v, list):
157
+ serialized_fields[key] = [serialize_fields(i, exclude_none=exclude_none) for i in v]
158
+ else:
159
+ serialized_fields[key] = str(v)
160
+
161
+ _type = URIRefManager[obj.__class__].get(obj.__class__.__name__, obj.__class__.__name__)
162
+
163
+ out = {"@type": _type, **serialized_fields}
164
+ # if no ID is given, generate a local one:
165
+ if obj.id is not None:
166
+ out["@id"] = obj.id
167
+ else:
168
+ out["@id"] = rdflib.BNode()
169
+ return out
170
+
171
+ serialization = serialize_fields(self, exclude_none=exclude_none)
172
+
169
173
  jsonld = {
170
174
  "@context": at_context,
171
- **serialize_fields(self, exclude_none=exclude_none)
175
+ **serialization
172
176
  }
173
177
  return jsonld
174
178
 
@@ -22,6 +22,7 @@ __package_dir__ = __this_dir__.parent / 'namespacelib'
22
22
 
23
23
  def generate_namespace_file_from_ttl(namespace: str,
24
24
  source: str,
25
+ ns: str,
25
26
  target_dir: Union[str, pathlib.Path, None] = None,
26
27
  fail=True):
27
28
  """Generate M4I_NAMESPACE.py file from m4i_context.jsonld
@@ -54,7 +55,7 @@ def generate_namespace_file_from_ttl(namespace: str,
54
55
  uri = str(s)
55
56
  f.write(f'\n {u} = URIRef("{uri}")')
56
57
 
57
- f.write('\n\n _NS = Namespace("https://qudt.org/vocab/unit/")')
58
+ f.write(f'\n\n _NS = Namespace("{ns}")')
58
59
 
59
60
  # f.write('\n\n')
60
61
  # f.write('\n\nQUDT_UNIT = _QUDT_UNIT()')
@@ -251,6 +252,7 @@ def qudt_unit():
251
252
  generate_namespace_file_from_ttl(
252
253
  namespace='qudt_unit',
253
254
  source='https://qudt.org/vocab/unit/',
255
+ ns='http://qudt.org/vocab/unit/',
254
256
  )
255
257
 
256
258
 
@@ -258,13 +260,15 @@ def qudt_quantitykind():
258
260
  generate_namespace_file_from_ttl(
259
261
  namespace='qudt_kind',
260
262
  source='https://qudt.org/vocab/quantitykind/',
263
+ ns='http://qudt.org/vocab/quantitykind/',
261
264
  )
262
265
 
263
266
 
264
267
  def schema():
265
268
  generate_namespace_file_from_ttl(
266
269
  namespace='schema',
267
- source='https://schema.org/version/latest/schemaorg-current-https.jsonld',
270
+ source='http://schema.org/version/latest/schemaorg-current-https.jsonld',
271
+ ns='http://schema.org/',
268
272
  )
269
273
 
270
274
 
@@ -296,29 +300,31 @@ def build_namespace_files():
296
300
  # f.write('from ._version import __version__\n')
297
301
 
298
302
  with open(__package_dir__ / '__init__.py', 'a') as f:
299
- m4i()
300
- f.write('from .m4i import M4I\n')
303
+ if False:
304
+ m4i()
305
+ f.write('from .m4i import M4I\n')
301
306
 
302
- obo()
303
- f.write('from .obo import OBO\n')
307
+ obo()
308
+ f.write('from .obo import OBO\n')
304
309
 
305
- qudt_unit()
306
- f.write('from .qudt_unit import QUDT_UNIT\n')
310
+ qudt_unit()
311
+ f.write('from .qudt_unit import QUDT_UNIT\n')
307
312
 
308
- qudt_quantitykind()
309
- f.write('from .qudt_kind import QUDT_KIND\n')
313
+ qudt_quantitykind()
314
+ f.write('from .qudt_kind import QUDT_KIND\n')
310
315
 
311
316
  pivmeta()
312
317
  f.write('from .pivmeta import PIVMETA\n')
313
318
 
314
- codemeta()
315
- f.write('from .codemeta import CODEMETA\n')
319
+ if False:
320
+ codemeta()
321
+ f.write('from .codemeta import CODEMETA\n')
316
322
 
317
- schema()
318
- f.write('from .schema import SCHEMA\n')
323
+ schema()
324
+ f.write('from .schema import SCHEMA\n')
319
325
 
320
- ssno()
321
- f.write('from .ssno import SSNO\n')
326
+ ssno()
327
+ f.write('from .ssno import SSNO\n')
322
328
 
323
329
  for jld in __package_dir__.glob('*.jsonld'):
324
330
  jld.unlink()
@@ -7,8 +7,8 @@ class LanguageExtension:
7
7
 
8
8
  class PIVMETA(DefinedNamespace):
9
9
  # uri = "https://w3id.org/nfdi4ing/metadata4ing#"
10
- # Generated with None version 0.2.0a3
11
- # Date: 2024-03-09 20:30:58.080699
10
+ # Generated with None version 0.2.8
11
+ # Date: 2024-03-21 14:56:33.894991
12
12
  _fail = True
13
13
  time: URIRef # ['time']
14
14
  BackgroundImageGeneration: URIRef # ['background image generation']
@@ -44,10 +44,12 @@ class PIVMETA(DefinedNamespace):
44
44
  fnumber: URIRef # ['fnumber']
45
45
  numberOfRecords: URIRef # ['number of records']
46
46
  ExperimentalImage: URIRef # ['experimental image']
47
+ GaussWindowWeightingFunction: URIRef # ['gauss']
47
48
  Interpolation: URIRef # ['interpolation']
48
49
  LeftRightFlip: URIRef # ['left right flip']
49
50
  ReEvaluateWithLargerSample: URIRef # ['re-evaluate with larger sample']
50
51
  SplitImage: URIRef # ['split image']
52
+ SquareWindowWeightingFunction: URIRef # ['square']
51
53
  SyntheticImage: URIRef # ['synthetic image']
52
54
  TopBottomFlip: URIRef # ['top bottom flip']
53
55
  TryLowerOrderPeaks: URIRef # ['try lower order peaks']
@@ -141,10 +143,12 @@ setattr(PIVMETA, "filename_pattern", PIVMETA.filenamePattern)
141
143
  setattr(PIVMETA, "fnumber", PIVMETA.fnumber)
142
144
  setattr(PIVMETA, "number_of_records", PIVMETA.numberOfRecords)
143
145
  setattr(PIVMETA, "experimental_image", PIVMETA.ExperimentalImage)
146
+ setattr(PIVMETA, "gauss", PIVMETA.GaussWindowWeightingFunction)
144
147
  setattr(PIVMETA, "interpolation", PIVMETA.Interpolation)
145
148
  setattr(PIVMETA, "left_right_flip", PIVMETA.LeftRightFlip)
146
149
  setattr(PIVMETA, "re-evaluate_with_larger_sample", PIVMETA.ReEvaluateWithLargerSample)
147
150
  setattr(PIVMETA, "split_image", PIVMETA.SplitImage)
151
+ setattr(PIVMETA, "square", PIVMETA.SquareWindowWeightingFunction)
148
152
  setattr(PIVMETA, "synthetic_image", PIVMETA.SyntheticImage)
149
153
  setattr(PIVMETA, "top_bottom_flip", PIVMETA.TopBottomFlip)
150
154
  setattr(PIVMETA, "try_lower_order_peaks", PIVMETA.TryLowerOrderPeaks)
@@ -22588,4 +22588,4 @@ class QUDT_KIND(DefinedNamespace):
22588
22588
  PhononMeanFreePath = URIRef("http://qudt.org/vocab/quantitykind/PhononMeanFreePath")
22589
22589
  ReynoldsNumber = URIRef("http://qudt.org/vocab/quantitykind/ReynoldsNumber")
22590
22590
 
22591
- _NS = Namespace("https://qudt.org/vocab/unit/")
22591
+ _NS = Namespace("http://qudt.org/vocab/quantitykind/")
@@ -16581,4 +16581,4 @@ class SCHEMA(DefinedNamespace):
16581
16581
  FoodService = URIRef("https://schema.org/FoodService")
16582
16582
  EventStatusType = URIRef("https://schema.org/EventStatusType")
16583
16583
 
16584
- _NS = Namespace("https://qudt.org/vocab/unit/")
16584
+ _NS = Namespace("https://schema.org/")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.2.6
3
+ Version: 0.2.8
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.6
3
+ version = 0.2.8
4
4
  author = Matthias Probst
5
5
  author_email = matthias.probst@kit.edu
6
6
  description = Utility library for the work with ontologies.
@@ -1,11 +1,8 @@
1
- import datetime
2
1
  import json
3
2
  import logging
4
3
  import pydantic
5
4
  import unittest
6
5
  from pydantic import EmailStr
7
- from rdflib import FOAF
8
- from typing import List
9
6
 
10
7
  from ontolutils import Thing, urirefs, namespaces
11
8
  from ontolutils import set_logging_level
@@ -38,48 +35,48 @@ class TestNamespaces(unittest.TestCase):
38
35
  thing2 = Thing(label='Thing 2', id='http://example.com/thing2')
39
36
  self.assertTrue(thing1 < thing2)
40
37
 
41
- def test_serialize_fields(self):
42
- from ontolutils.classes.thing import serialize_fields
43
- self.assertEqual(serialize_fields(1), 1)
44
- self.assertEqual(serialize_fields(1.1), 1.1)
45
- self.assertEqual(serialize_fields('1'), '1')
46
- self.assertEqual(serialize_fields(True), True)
47
- thing = Thing(label='Thing 1')
48
-
49
- class RandomClass:
50
- """Random Class"""
51
-
52
- rc = RandomClass()
53
- self.assertEqual(serialize_fields(rc), rc)
54
-
55
- self.assertDictEqual(serialize_fields(Thing(id='_:b1', label='Thing 1')),
56
- {'@type': 'owl:Thing', 'rdfs:label': 'Thing 1', '@id': '_:b1'})
57
-
58
- @namespaces(owl='http://www.w3.org/2002/07/owl#',
59
- local='http://example.org/')
60
- @urirefs(Process='local:Process',
61
- startTime='local:startTime',
62
- listOfTimes='local:listOfTimes')
63
- class Process(Thing):
64
- """Process Thing"""
65
- startTime: datetime.datetime = None
66
- listOfTimes: List[datetime.datetime] = None
67
-
68
- process = Process(id='_:b1', label='Process 1',
69
- startTime=datetime.datetime(2021, 1, 1))
70
- self.assertEqual(serialize_fields(process),
71
- {'@type': 'local:Process', 'rdfs:label': 'Process 1', 'local:startTime': '2021-01-01T00:00:00',
72
- '@id': '_:b1'})
73
-
74
- process = Process(id='_:b1',
75
- label='Process 1',
76
- listOfTimes=[datetime.datetime(2021, 1, 1),
77
- datetime.datetime(2021, 1, 2)])
78
-
79
- self.assertEqual(serialize_fields(process),
80
- {'@type': 'local:Process', 'rdfs:label': 'Process 1',
81
- 'local:listOfTimes': ['2021-01-01T00:00:00', '2021-01-02T00:00:00'],
82
- '@id': '_:b1'})
38
+ # def test_serialize_fields(self):
39
+ # from ontolutils.classes.thing import serialize_fields
40
+ # self.assertEqual(serialize_fields(1), 1)
41
+ # self.assertEqual(serialize_fields(1.1), 1.1)
42
+ # self.assertEqual(serialize_fields('1'), '1')
43
+ # self.assertEqual(serialize_fields(True), True)
44
+ # thing = Thing(label='Thing 1')
45
+ #
46
+ # class RandomClass:
47
+ # """Random Class"""
48
+ #
49
+ # rc = RandomClass()
50
+ # self.assertEqual(serialize_fields(rc), rc)
51
+ #
52
+ # self.assertDictEqual(serialize_fields(Thing(id='_:b1', label='Thing 1')),
53
+ # {'@type': 'owl:Thing', 'rdfs:label': 'Thing 1', '@id': '_:b1'})
54
+ #
55
+ # @namespaces(owl='http://www.w3.org/2002/07/owl#',
56
+ # local='http://example.org/')
57
+ # @urirefs(Process='local:Process',
58
+ # startTime='local:startTime',
59
+ # listOfTimes='local:listOfTimes')
60
+ # class Process(Thing):
61
+ # """Process Thing"""
62
+ # startTime: datetime.datetime = None
63
+ # listOfTimes: List[datetime.datetime] = None
64
+ #
65
+ # process = Process(id='_:b1', label='Process 1',
66
+ # startTime=datetime.datetime(2021, 1, 1))
67
+ # self.assertEqual(serialize_fields(process),
68
+ # {'@type': 'local:Process', 'rdfs:label': 'Process 1', 'local:startTime': '2021-01-01T00:00:00',
69
+ # '@id': '_:b1'})
70
+ #
71
+ # process = Process(id='_:b1',
72
+ # label='Process 1',
73
+ # listOfTimes=[datetime.datetime(2021, 1, 1),
74
+ # datetime.datetime(2021, 1, 2)])
75
+ #
76
+ # self.assertEqual(serialize_fields(process),
77
+ # {'@type': 'local:Process', 'rdfs:label': 'Process 1',
78
+ # 'local:listOfTimes': ['2021-01-01T00:00:00', '2021-01-02T00:00:00'],
79
+ # '@id': '_:b1'})
83
80
 
84
81
  def test__repr_html_(self):
85
82
  thing = Thing(label='Thing 1')
@@ -177,12 +174,12 @@ class TestNamespaces(unittest.TestCase):
177
174
  """
178
175
  mbox: EmailStr = None
179
176
 
180
- @namespaces(schema="https://schema.org/")
177
+ @namespaces(schema="http://schema.org/")
181
178
  @urirefs(Organization='prov:Organization')
182
179
  class Organization(Agent):
183
180
  """Pydantic Model for https://www.w3.org/ns/prov/Agent"""
184
181
 
185
- @namespaces(schema="https://schema.org/")
182
+ @namespaces(schema="http://schema.org/")
186
183
  @urirefs(Person='foaf:Person',
187
184
  affiliation='schema:affiliation')
188
185
  class Person(Agent):
@@ -227,7 +224,8 @@ class TestNamespaces(unittest.TestCase):
227
224
  foaf="http://xmlns.com/foaf/0.1/")
228
225
  @urirefs(Person='prov:Person',
229
226
  firstName='foaf:firstName',
230
- lastName=FOAF.lastName,
227
+ # lastName=FOAF.lastName,
228
+ lastName='foaf:lastName',
231
229
  mbox='foaf:mbox')
232
230
  class Person(Thing):
233
231
  firstName: str
@@ -239,14 +237,13 @@ class TestNamespaces(unittest.TestCase):
239
237
  "@context": {
240
238
  "owl": "http://www.w3.org/2002/07/owl#",
241
239
  "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
242
- "lastName": "http://xmlns.com/foaf/0.1/",
240
+ "foaf": "http://xmlns.com/foaf/0.1/",
243
241
  "prov": "http://www.w3.org/ns/prov#",
244
- "foaf": "http://xmlns.com/foaf/0.1/"
245
242
  },
246
243
  "@id": "local:cde4c79c-21f2-4ab7-b01d-28de6e4aade4",
247
244
  "@type": "prov:Person",
248
245
  "foaf:firstName": "John",
249
- "lastName": "Doe"
246
+ "foaf:lastName": "Doe"
250
247
  }
251
248
  print(p.model_dump_jsonld())
252
249
 
@@ -35,7 +35,7 @@ class TestQuery(unittest.TestCase):
35
35
 
36
36
  def test_dquery(self):
37
37
  test_data = """{"@context": {"foaf": "http://xmlns.com/foaf/0.1/", "prov": "http://www.w3.org/ns/prov#",
38
- "schema": "http://www.w3.org/2000/01/rdf-schema#", "schema": "https://schema.org/"},
38
+ "schema": "http://www.w3.org/2000/01/rdf-schema#", "schema": "http://schema.org/"},
39
39
  "@id": "local:testperson",
40
40
  "@type": "prov:Person",
41
41
  "foaf:firstName": "John",
@@ -62,7 +62,7 @@ class TestQuery(unittest.TestCase):
62
62
  source=codemeta_filename,
63
63
  context={"schema": "http://schema.org/"}
64
64
  )
65
- isinstance(res, list)
65
+ self.assertIsInstance(res, list)
66
66
  self.assertTrue(len(res) == 1)
67
67
  self.assertTrue(res[0]['version'] == __version__)
68
68
  self.assertTrue('author' in res[0])
File without changes
File without changes
File without changes
File without changes