mustrd 0.1.8__py3-none-any.whl → 0.2.0a1__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.
- mustrd/README.adoc +201 -201
- mustrd/execute_update_spec.py +18 -0
- mustrd/logger_setup.py +48 -48
- mustrd/mustrd.py +842 -788
- mustrd/mustrdAnzo.py +208 -236
- mustrd/mustrdGraphDb.py +128 -125
- mustrd/mustrdRdfLib.py +56 -56
- mustrd/namespace.py +104 -125
- mustrd/run.py +95 -106
- mustrd/spec_component.py +617 -682
- mustrd/triple_store_dispatch.py +115 -0
- mustrd/utils.py +30 -38
- {mustrd-0.1.8.dist-info → mustrd-0.2.0a1.dist-info}/LICENSE +21 -21
- mustrd-0.2.0a1.dist-info/METADATA +24 -0
- mustrd-0.2.0a1.dist-info/RECORD +17 -0
- {mustrd-0.1.8.dist-info → mustrd-0.2.0a1.dist-info}/WHEEL +1 -1
- mustrd/TestResult.py +0 -136
- mustrd/model/catalog-v001.xml +0 -5
- mustrd/model/mustrdShapes.ttl +0 -253
- mustrd/model/mustrdTestOntology.ttl +0 -51
- mustrd/model/mustrdTestShapes.ttl +0 -24
- mustrd/model/ontology.ttl +0 -494
- mustrd/model/test-resources/resources.ttl +0 -60
- mustrd/model/triplestoreOntology.ttl +0 -174
- mustrd/model/triplestoreshapes.ttl +0 -42
- mustrd/mustrdTestPlugin.py +0 -328
- mustrd/steprunner.py +0 -166
- mustrd/templates/md_ResultList_leaf_template.jinja +0 -19
- mustrd/templates/md_ResultList_template.jinja +0 -9
- mustrd/templates/md_stats_template.jinja +0 -3
- mustrd/test/test_mustrd.py +0 -5
- mustrd-0.1.8.dist-info/METADATA +0 -97
- mustrd-0.1.8.dist-info/RECORD +0 -31
- mustrd-0.1.8.dist-info/entry_points.txt +0 -3
mustrd/run.py
CHANGED
@@ -1,106 +1,95 @@
|
|
1
|
-
"""
|
2
|
-
MIT License
|
3
|
-
|
4
|
-
Copyright (c) 2023 Semantic Partners Ltd
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
8
|
-
in the Software without restriction, including without limitation the rights
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
11
|
-
furnished to do so, subject to the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
14
|
-
copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
SOFTWARE.
|
23
|
-
"""
|
24
|
-
|
25
|
-
import argparse
|
26
|
-
import logger_setup
|
27
|
-
import sys
|
28
|
-
import os
|
29
|
-
from rdflib import Graph
|
30
|
-
from
|
31
|
-
from pathlib import Path
|
32
|
-
from
|
33
|
-
from
|
34
|
-
|
35
|
-
log = logger_setup.setup_logger(__name__)
|
36
|
-
|
37
|
-
|
38
|
-
def parse_args() -> argparse.Namespace:
|
39
|
-
parser = argparse.ArgumentParser()
|
40
|
-
parser.add_argument("-p", "--put", help="Path under test - required", required=True)
|
41
|
-
parser.add_argument("-v", "--verbose", help="verbose logging", action='store_true')
|
42
|
-
parser.add_argument("-c", "--config", help="Path to triple store configuration", default=None)
|
43
|
-
parser.add_argument("-
|
44
|
-
parser.add_argument("-
|
45
|
-
parser.add_argument("-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
log.info(f"
|
68
|
-
triple_stores =
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
specs, skipped_spec_results = \
|
98
|
-
get_specs(valid_spec_uris, spec_graph, triple_stores, run_config)
|
99
|
-
|
100
|
-
results = invalid_spec_results + skipped_spec_results + run_specs(specs)
|
101
|
-
|
102
|
-
review_results(results, verbose)
|
103
|
-
|
104
|
-
|
105
|
-
if __name__ == "__main__":
|
106
|
-
main(sys.argv[1:])
|
1
|
+
"""
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Copyright (c) 2023 Semantic Partners Ltd
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
23
|
+
"""
|
24
|
+
|
25
|
+
import argparse
|
26
|
+
import logger_setup
|
27
|
+
import sys
|
28
|
+
import os
|
29
|
+
from rdflib import Graph
|
30
|
+
from mustrd import run_specs, get_triple_stores, review_results, validate_specs
|
31
|
+
from pathlib import Path
|
32
|
+
from namespace import MUST
|
33
|
+
from utils import get_project_root
|
34
|
+
|
35
|
+
log = logger_setup.setup_logger(__name__)
|
36
|
+
|
37
|
+
|
38
|
+
def parse_args() -> argparse.Namespace:
|
39
|
+
parser = argparse.ArgumentParser()
|
40
|
+
parser.add_argument("-p", "--put", help="Path under test - required", required=True)
|
41
|
+
parser.add_argument("-v", "--verbose", help="verbose logging", action='store_true')
|
42
|
+
parser.add_argument("-c", "--config", help="Path to triple store configuration", default=None)
|
43
|
+
parser.add_argument("-g", "--given", help="Folder for given files", default=None)
|
44
|
+
parser.add_argument("-w", "--when", help="Folder for when files", default=None)
|
45
|
+
parser.add_argument("-t", "--then", help="Folder for then files", default=None)
|
46
|
+
|
47
|
+
return parser.parse_args()
|
48
|
+
|
49
|
+
|
50
|
+
# https://github.com/Semantic-partners/mustrd/issues/108
|
51
|
+
def main(argv):
|
52
|
+
given_path = when_path = then_path = None
|
53
|
+
project_root = get_project_root()
|
54
|
+
args = parse_args()
|
55
|
+
path_under_test = Path(args.put)
|
56
|
+
log.info(f"Path under test is {path_under_test}")
|
57
|
+
|
58
|
+
verbose = args.verbose
|
59
|
+
if verbose:
|
60
|
+
log.info(f"Verbose set")
|
61
|
+
|
62
|
+
if args.config:
|
63
|
+
triplestore_spec_path = Path(args.config)
|
64
|
+
log.info(f"Path for triple store configuration is {triplestore_spec_path}")
|
65
|
+
triple_stores = get_triple_stores(Graph().parse(triplestore_spec_path))
|
66
|
+
else:
|
67
|
+
log.info(f"No triple store configuration added, running default configuration")
|
68
|
+
triple_stores = [{'type': MUST.RdfLib}]
|
69
|
+
|
70
|
+
if args.given:
|
71
|
+
given_path = Path(args.given)
|
72
|
+
log.info(f"Path for given folder is {given_path}")
|
73
|
+
|
74
|
+
if args.when:
|
75
|
+
when_path = Path(args.when)
|
76
|
+
log.info(f"Path for when folder is {when_path}")
|
77
|
+
|
78
|
+
if args.then:
|
79
|
+
then_path = Path(args.then)
|
80
|
+
log.info(f"Path for then folder is {then_path}")
|
81
|
+
|
82
|
+
shacl_graph = Graph().parse(Path(os.path.join(project_root, "model/mustrdShapes.ttl")))
|
83
|
+
ont_graph = Graph().parse(Path(os.path.join(project_root, "model/ontology.ttl")))
|
84
|
+
|
85
|
+
valid_spec_uris, spec_graph, invalid_spec_results = \
|
86
|
+
validate_specs(path_under_test, triple_stores, shacl_graph, ont_graph)
|
87
|
+
|
88
|
+
results = \
|
89
|
+
run_specs(valid_spec_uris, spec_graph, invalid_spec_results, triple_stores, given_path, when_path, then_path)
|
90
|
+
|
91
|
+
review_results(results, verbose)
|
92
|
+
|
93
|
+
|
94
|
+
if __name__ == "__main__":
|
95
|
+
main(sys.argv[1:])
|