spdx-python-model 0.0.3__py3-none-any.whl → 0.0.5__py3-none-any.whl
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/bindings/v3_0_1/__init__.py +13 -0
- spdx_python_model/bindings/v3_0_1/__main__.py +12 -0
- spdx_python_model/bindings/v3_0_1/cmd.py +75 -0
- spdx_python_model/bindings/{v3_0_1.py → v3_0_1/model.py} +3145 -2666
- spdx_python_model/bindings/v3_0_1/model.pyi +2755 -0
- spdx_python_model/py.typed +0 -0
- spdx_python_model/version.py +1 -1
- {spdx_python_model-0.0.3.dist-info → spdx_python_model-0.0.5.dist-info}/METADATA +3 -1
- spdx_python_model-0.0.5.dist-info/RECORD +13 -0
- {spdx_python_model-0.0.3.dist-info → spdx_python_model-0.0.5.dist-info}/WHEEL +1 -1
- spdx_python_model-0.0.3.dist-info/RECORD +0 -8
- {spdx_python_model-0.0.3.dist-info → spdx_python_model-0.0.5.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# This file was auto-generated by shacl2code 1.0.1. DO NOT MANUALLY MODIFY IT
|
|
4
|
+
#
|
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
|
|
7
|
+
from .model import * # noqa: F401, F403
|
|
8
|
+
|
|
9
|
+
# fmt: off
|
|
10
|
+
"""Format Guard"""
|
|
11
|
+
from .cmd import main # noqa: F401, I100, I202
|
|
12
|
+
"""Format Guard"""
|
|
13
|
+
# fmt on
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# This file was auto-generated by shacl2code 1.0.1. DO NOT MANUALLY MODIFY IT
|
|
4
|
+
#
|
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Iterable, List
|
|
10
|
+
|
|
11
|
+
from .model import (
|
|
12
|
+
JSONLDDeserializer,
|
|
13
|
+
JSONLDSerializer,
|
|
14
|
+
ListProxy,
|
|
15
|
+
SHACLObject,
|
|
16
|
+
SHACLObjectSet,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def print_tree(objects: Iterable[SHACLObject], all_fields: bool = False) -> None:
|
|
21
|
+
"""
|
|
22
|
+
Print object tree
|
|
23
|
+
"""
|
|
24
|
+
seen = set()
|
|
25
|
+
|
|
26
|
+
def callback(value: Any, path: List[str]) -> bool:
|
|
27
|
+
s = (" " * (len(path) - 1)) + f"{path[-1]}"
|
|
28
|
+
if isinstance(value, SHACLObject):
|
|
29
|
+
s += f" {value} ({id(value)})"
|
|
30
|
+
is_empty = False
|
|
31
|
+
elif isinstance(value, ListProxy):
|
|
32
|
+
is_empty = len(value) == 0
|
|
33
|
+
if is_empty:
|
|
34
|
+
s += " []"
|
|
35
|
+
else:
|
|
36
|
+
s += f" {value!r}"
|
|
37
|
+
is_empty = value is None
|
|
38
|
+
|
|
39
|
+
if all_fields or not is_empty:
|
|
40
|
+
print(s)
|
|
41
|
+
|
|
42
|
+
if isinstance(value, SHACLObject):
|
|
43
|
+
if value in seen:
|
|
44
|
+
return False
|
|
45
|
+
seen.add(value)
|
|
46
|
+
return True
|
|
47
|
+
|
|
48
|
+
return True
|
|
49
|
+
|
|
50
|
+
for o in objects:
|
|
51
|
+
o.walk(callback)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def main() -> int:
|
|
55
|
+
parser = argparse.ArgumentParser(description="Python SHACL model test")
|
|
56
|
+
parser.add_argument("infile", type=Path, help="Input file")
|
|
57
|
+
parser.add_argument("--print", action="store_true", help="Print object tree")
|
|
58
|
+
parser.add_argument("--outfile", type=Path, help="Output file")
|
|
59
|
+
|
|
60
|
+
args = parser.parse_args()
|
|
61
|
+
|
|
62
|
+
objectset = SHACLObjectSet()
|
|
63
|
+
with args.infile.open("r") as f:
|
|
64
|
+
d = JSONLDDeserializer()
|
|
65
|
+
d.read(f, objectset)
|
|
66
|
+
|
|
67
|
+
if args.print:
|
|
68
|
+
print_tree(objectset.objects)
|
|
69
|
+
|
|
70
|
+
if args.outfile:
|
|
71
|
+
with args.outfile.open("wb") as f:
|
|
72
|
+
s = JSONLDSerializer()
|
|
73
|
+
s.write(objectset, f)
|
|
74
|
+
|
|
75
|
+
return 0
|