spdx-python-model 0.0.3__tar.gz → 0.0.4__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.
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/PKG-INFO +1 -1
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/pyproject.toml +1 -1
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/src/spdx_python_model/bindings/v3_0_1.py +27 -11
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/src/spdx_python_model/version.py +1 -1
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/.github/workflows/publish.yaml +0 -0
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/.github/workflows/test.yaml +0 -0
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/.gitignore +0 -0
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/LICENSE +0 -0
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/README.md +0 -0
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/gen/generate-bindings +0 -0
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/src/spdx_python_model/__init__.py +0 -0
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/src/spdx_python_model/bindings/__init__.py +0 -0
- {spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/tests/test_import.py +0 -0
{spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/src/spdx_python_model/bindings/v3_0_1.py
RENAMED
|
@@ -33,8 +33,10 @@ from typing import (
|
|
|
33
33
|
Set,
|
|
34
34
|
Tuple,
|
|
35
35
|
Type,
|
|
36
|
+
TypeVar,
|
|
36
37
|
Union,
|
|
37
38
|
cast,
|
|
39
|
+
overload,
|
|
38
40
|
)
|
|
39
41
|
|
|
40
42
|
|
|
@@ -540,10 +542,9 @@ class EnumProp(IRIProp):
|
|
|
540
542
|
def validate(self, value) -> None:
|
|
541
543
|
super().validate(value)
|
|
542
544
|
|
|
543
|
-
|
|
544
|
-
if value not in valid_values:
|
|
545
|
+
if value not in self.iri_values():
|
|
545
546
|
raise ValueError(
|
|
546
|
-
f"'{value}' is not a valid value. Choose one of {' '.join(
|
|
547
|
+
f"'{value}' is not a valid value. Choose one of {' '.join(self.iri_values())}"
|
|
547
548
|
)
|
|
548
549
|
|
|
549
550
|
def encode(self, encoder, value, state) -> None:
|
|
@@ -616,6 +617,7 @@ def register(
|
|
|
616
617
|
|
|
617
618
|
register_lock = threading.Lock()
|
|
618
619
|
NAMED_INDIVIDUALS: Set[str] = set()
|
|
620
|
+
T_SHACLObject = TypeVar("T_SHACLObject", bound="SHACLObject")
|
|
619
621
|
|
|
620
622
|
|
|
621
623
|
@functools.total_ordering
|
|
@@ -861,7 +863,7 @@ class SHACLObject(object):
|
|
|
861
863
|
) as obj_s:
|
|
862
864
|
self._encode_properties(obj_s, state)
|
|
863
865
|
|
|
864
|
-
def _encode_properties(self, encoder, state):
|
|
866
|
+
def _encode_properties(self, encoder, state) -> None:
|
|
865
867
|
for iri, prop, min_count, max_count, pyname, compact in self.__iter_props():
|
|
866
868
|
value = self.__dict__["_obj_data"][iri]
|
|
867
869
|
if prop.elide(value):
|
|
@@ -921,7 +923,9 @@ class SHACLObject(object):
|
|
|
921
923
|
|
|
922
924
|
return obj
|
|
923
925
|
|
|
924
|
-
def _decode_properties(
|
|
926
|
+
def _decode_properties(
|
|
927
|
+
self, decoder, objectset: Optional[SHACLObjectSet] = None
|
|
928
|
+
) -> None:
|
|
925
929
|
for key in decoder.object_keys():
|
|
926
930
|
if not self._decode_prop(decoder, key, objectset=objectset):
|
|
927
931
|
raise KeyError(f"Unknown property '{key}'")
|
|
@@ -1019,7 +1023,9 @@ class SHACLExtensibleObject(SHACLObject):
|
|
|
1019
1023
|
obj = cls(typ)
|
|
1020
1024
|
return obj
|
|
1021
1025
|
|
|
1022
|
-
def _decode_properties(
|
|
1026
|
+
def _decode_properties(
|
|
1027
|
+
self, decoder, objectset: Optional[SHACLObjectSet] = None
|
|
1028
|
+
) -> None:
|
|
1023
1029
|
def decode_value(d):
|
|
1024
1030
|
if not d.is_list():
|
|
1025
1031
|
return d.read_value()
|
|
@@ -1042,7 +1048,7 @@ class SHACLExtensibleObject(SHACLObject):
|
|
|
1042
1048
|
with decoder.read_property(key) as prop_d:
|
|
1043
1049
|
self.__dict__["_obj_data"][key] = decode_value(prop_d)
|
|
1044
1050
|
|
|
1045
|
-
def _encode_properties(self, encoder, state):
|
|
1051
|
+
def _encode_properties(self, encoder, state) -> None:
|
|
1046
1052
|
super()._encode_properties(encoder, state)
|
|
1047
1053
|
if self.CLOSED:
|
|
1048
1054
|
return
|
|
@@ -1274,8 +1280,17 @@ class SHACLObjectSet(object):
|
|
|
1274
1280
|
for child in o.iter_objects(recursive=True, visited=visited):
|
|
1275
1281
|
yield child
|
|
1276
1282
|
|
|
1283
|
+
@overload
|
|
1284
|
+
def foreach_type(
|
|
1285
|
+
self, typ: str, *, match_subclass: bool = True
|
|
1286
|
+
) -> Iterator[SHACLObject]: ...
|
|
1287
|
+
@overload
|
|
1288
|
+
def foreach_type(
|
|
1289
|
+
self, typ: Type[T_SHACLObject], *, match_subclass: bool = True
|
|
1290
|
+
) -> Iterator[T_SHACLObject]: ...
|
|
1291
|
+
|
|
1277
1292
|
def foreach_type(
|
|
1278
|
-
self, typ: Union[str,
|
|
1293
|
+
self, typ: Union[str, Type[T_SHACLObject]], *, match_subclass: bool = True
|
|
1279
1294
|
) -> Iterable[SHACLObject]:
|
|
1280
1295
|
"""
|
|
1281
1296
|
Iterate over each object of a specified type (or subclass there of)
|
|
@@ -1287,15 +1302,16 @@ class SHACLObjectSet(object):
|
|
|
1287
1302
|
if not isinstance(typ, str):
|
|
1288
1303
|
if not isinstance(typ, type) or not issubclass(typ, SHACLObject):
|
|
1289
1304
|
raise TypeError(f"Type must be derived from SHACLObject, got {typ}")
|
|
1290
|
-
|
|
1291
|
-
|
|
1305
|
+
# This intermediate step is necessary for pyrefly...
|
|
1306
|
+
typ_class: Type[SHACLObject] = typ
|
|
1307
|
+
typ = typ_class._OBJ_TYPE
|
|
1292
1308
|
|
|
1293
1309
|
if typ not in self.obj_by_type:
|
|
1294
1310
|
return
|
|
1295
1311
|
|
|
1296
1312
|
for exact, o in self.obj_by_type[typ]:
|
|
1297
1313
|
if match_subclass or exact:
|
|
1298
|
-
yield o
|
|
1314
|
+
yield cast(T_SHACLObject, o)
|
|
1299
1315
|
|
|
1300
1316
|
def merge(self, *objectsets) -> "SHACLObjectSet":
|
|
1301
1317
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{spdx_python_model-0.0.3 → spdx_python_model-0.0.4}/src/spdx_python_model/bindings/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|