ogc-na 0.3.57__tar.gz → 0.4.1__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.
Potentially problematic release.
This version of ogc-na might be problematic. Click here for more details.
- {ogc_na-0.3.57 → ogc_na-0.4.1}/PKG-INFO +2 -2
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/_version.py +9 -4
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/ingest_json.py +52 -9
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/provenance.py +18 -2
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/update_vocabs.py +79 -29
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc_na.egg-info/PKG-INFO +2 -2
- {ogc_na-0.3.57 → ogc_na-0.4.1}/.github/workflows/mkdocs.yml +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/.github/workflows/python-publish.yml +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/.gitignore +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/MANIFEST.in +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/README.md +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/docs/examples.md +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/docs/gen_ref_pages.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/docs/index.md +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/docs/jsonld-uplift.md +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/docs/tutorials.md +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/mkdocs.yml +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/__init__.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/annotate_schema.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/domain_config.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/download.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/exceptions.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/gsp.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/input_filters/__init__.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/input_filters/csv.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/input_filters/xlsx.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/input_filters/xml.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/models.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/profile.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/util.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc/na/validation.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc_na.egg-info/SOURCES.txt +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc_na.egg-info/dependency_links.txt +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc_na.egg-info/requires.txt +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/ogc_na.egg-info/top_level.txt +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/pyproject.toml +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/rdf/catalog-v001.xml +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/rdf/domaincfg.vocab.ttl +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/requirements.txt +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/setup.cfg +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/setup.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/__init__.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/empty.ttl +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/headers.csv +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/headers.xlsx +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/no-headers.csv +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/no-headers.xlsx +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/profile_tree.ttl +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/profile_tree_cyclic.ttl +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/sample-context.jsonld +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/sample-schema-prop-c.yml +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/sample-schema.yml +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/schema-anchors.json +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/schema-vocab.yml +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/two-sheets.xlsx +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/data/uplift_context_valid.yml +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/test_annotate_schema.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/test_ingest_json.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/test_input_filters_csv.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/test_input_filters_xlsx.py +0 -0
- {ogc_na-0.3.57 → ogc_na-0.4.1}/test/test_profile.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ogc_na
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: OGC Naming Authority tools
|
|
5
5
|
Author-email: Rob Atkinson <ratkinson@ogc.org>, Piotr Zaborowski <pzaborowski@ogc.org>, Alejandro Villar <avillar@ogc.org>
|
|
6
6
|
Project-URL: Homepage, https://github.com/opengeospatial/ogc-na-tools/
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
# file generated by
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
5
|
+
|
|
3
6
|
TYPE_CHECKING = False
|
|
4
7
|
if TYPE_CHECKING:
|
|
5
|
-
from typing import Tuple
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
from typing import Union
|
|
10
|
+
|
|
6
11
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
7
12
|
else:
|
|
8
13
|
VERSION_TUPLE = object
|
|
@@ -12,5 +17,5 @@ __version__: str
|
|
|
12
17
|
__version_tuple__: VERSION_TUPLE
|
|
13
18
|
version_tuple: VERSION_TUPLE
|
|
14
19
|
|
|
15
|
-
__version__ = version = '0.
|
|
16
|
-
__version_tuple__ = version_tuple = (0,
|
|
20
|
+
__version__ = version = '0.4.1'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 4, 1)
|
|
@@ -45,7 +45,7 @@ from typing import Union, Optional, Sequence, cast, Iterable, Any
|
|
|
45
45
|
import jq
|
|
46
46
|
from jsonpath_ng.ext import parse as json_path_parse
|
|
47
47
|
from jsonschema import validate as json_validate
|
|
48
|
-
from rdflib import Graph, DC, DCTERMS, SKOS, OWL, RDF, RDFS, XSD, DCAT
|
|
48
|
+
from rdflib import Graph, DC, DCTERMS, SKOS, OWL, RDF, RDFS, XSD, DCAT, URIRef
|
|
49
49
|
from rdflib.namespace import Namespace, DefinedNamespace
|
|
50
50
|
|
|
51
51
|
from ogc.na import util, profile
|
|
@@ -418,7 +418,8 @@ def process_file(input_fn: str | Path,
|
|
|
418
418
|
provenance_base_uri: str | bool | None = None,
|
|
419
419
|
provenance_process_id: str | None = None,
|
|
420
420
|
fetch_url_whitelist: bool | Sequence[str] | None = None,
|
|
421
|
-
transform_args: dict | None = None
|
|
421
|
+
transform_args: dict | None = None,
|
|
422
|
+
generated_provenance_classes: bool | list[str | URIRef] = False) -> UpliftResult | None:
|
|
422
423
|
"""
|
|
423
424
|
Process input file and generate output RDF files.
|
|
424
425
|
|
|
@@ -439,6 +440,8 @@ def process_file(input_fn: str | Path,
|
|
|
439
440
|
retrieving them. If None, it will not be used; if empty sequence or False, remote fetching operations will
|
|
440
441
|
throw an exception
|
|
441
442
|
:param transform_args: Additional arguments to pass as variables to the jq transform
|
|
443
|
+
:param generated_provenance_classes: List of classes whose instances will be included in the "generated"
|
|
444
|
+
provenance metadata. If `True`, all subjects in the output graph will be added.
|
|
442
445
|
:return: List of output files created
|
|
443
446
|
"""
|
|
444
447
|
|
|
@@ -489,16 +492,16 @@ def process_file(input_fn: str | Path,
|
|
|
489
492
|
|
|
490
493
|
provenance_metadata: ProvenanceMetadata | None = None
|
|
491
494
|
if provenance_base_uri is not False:
|
|
492
|
-
used = [FileProvenanceMetadata(filename=input_fn, mime_type='application/json')]
|
|
493
|
-
used.extend(FileProvenanceMetadata(filename=c, mime_type='application/yaml') for c in provenance_contexts)
|
|
494
495
|
provenance_metadata = ProvenanceMetadata(
|
|
495
|
-
used=used,
|
|
496
496
|
batch_activity_id=provenance_process_id,
|
|
497
497
|
base_uri=provenance_base_uri,
|
|
498
498
|
root_directory=os.getcwd(),
|
|
499
499
|
start=start_time,
|
|
500
500
|
end_auto=True,
|
|
501
501
|
)
|
|
502
|
+
provenance_metadata.add_used(FileProvenanceMetadata(filename=input_fn, mime_type='application/json'))
|
|
503
|
+
provenance_metadata.add_used(FileProvenanceMetadata(filename=c, mime_type='application/yaml')
|
|
504
|
+
for c in provenance_contexts)
|
|
502
505
|
|
|
503
506
|
if transform_args is None:
|
|
504
507
|
transform_args = {}
|
|
@@ -518,13 +521,29 @@ def process_file(input_fn: str | Path,
|
|
|
518
521
|
|
|
519
522
|
uplift_result.input_file = input_fn
|
|
520
523
|
|
|
524
|
+
if provenance_metadata and generated_provenance_classes:
|
|
525
|
+
if generated_provenance_classes is True:
|
|
526
|
+
# add all subjects to "generated"
|
|
527
|
+
provenance_metadata.add_generated(
|
|
528
|
+
FileProvenanceMetadata(uri=str(s), use_bnode=False)
|
|
529
|
+
for s in uplift_result.graph.subjects()
|
|
530
|
+
if isinstance(s, URIRef)
|
|
531
|
+
)
|
|
532
|
+
elif generated_provenance_classes:
|
|
533
|
+
provenance_metadata.add_generated(
|
|
534
|
+
FileProvenanceMetadata(uri=str(s), use_bnode=False)
|
|
535
|
+
for cls in generated_provenance_classes
|
|
536
|
+
for s in uplift_result.graph.subjects(predicate=RDF.type, object=URIRef(cls))
|
|
537
|
+
if isinstance(s, URIRef)
|
|
538
|
+
)
|
|
539
|
+
|
|
521
540
|
# False = do not generate
|
|
522
541
|
# None = auto filename
|
|
523
542
|
# - = stdout
|
|
524
543
|
if ttl_fn is not False:
|
|
525
544
|
if ttl_fn == '-':
|
|
526
545
|
if provenance_metadata:
|
|
527
|
-
provenance_metadata.
|
|
546
|
+
provenance_metadata.add_generated(FileProvenanceMetadata(mime_type='text/turtle', use_bnode=False))
|
|
528
547
|
generate_provenance(uplift_result.graph, provenance_metadata)
|
|
529
548
|
print(uplift_result.graph.serialize(format='ttl'))
|
|
530
549
|
else:
|
|
@@ -533,9 +552,9 @@ def process_file(input_fn: str | Path,
|
|
|
533
552
|
if input_fn.suffix != '.ttl' \
|
|
534
553
|
else input_fn.with_suffix(input_fn.suffix + '.ttl')
|
|
535
554
|
if provenance_metadata:
|
|
536
|
-
provenance_metadata.
|
|
555
|
+
provenance_metadata.add_generated(FileProvenanceMetadata(filename=ttl_fn,
|
|
537
556
|
mime_type='text/turtle',
|
|
538
|
-
use_bnode=False)
|
|
557
|
+
use_bnode=False))
|
|
539
558
|
generate_provenance(uplift_result.graph, provenance_metadata)
|
|
540
559
|
uplift_result.graph.serialize(destination=ttl_fn, format='ttl')
|
|
541
560
|
uplift_result.output_files.append(ttl_fn)
|
|
@@ -656,7 +675,8 @@ def process(input_files: str | Path | Sequence[str | Path],
|
|
|
656
675
|
provenance_base_uri: Optional[Union[str, bool]] = None,
|
|
657
676
|
fetch_url_whitelist: Optional[Union[Sequence, bool]] = None,
|
|
658
677
|
transform_args: dict | None = None,
|
|
659
|
-
file_filter: str | re.Pattern = None
|
|
678
|
+
file_filter: str | re.Pattern = None,
|
|
679
|
+
generated_provenance_classes: bool | list[str | URIRef] = False) -> list[UpliftResult]:
|
|
660
680
|
"""
|
|
661
681
|
Performs the JSON-LD uplift process.
|
|
662
682
|
|
|
@@ -678,6 +698,8 @@ def process(input_files: str | Path | Sequence[str | Path],
|
|
|
678
698
|
throw an exception
|
|
679
699
|
:param transform_args: Additional arguments to pass as variables to the jq transform
|
|
680
700
|
:param file_filter: Filename filter for input files
|
|
701
|
+
:param generated_provenance_classes: List of classes whose instances will be included in the "generated"
|
|
702
|
+
provenance metadata. If `True`, all subjects in the output graph will be added.
|
|
681
703
|
:return: a list of JSON-LD and/or Turtle output files
|
|
682
704
|
"""
|
|
683
705
|
result: list[UpliftResult] = []
|
|
@@ -729,6 +751,7 @@ def process(input_files: str | Path | Sequence[str | Path],
|
|
|
729
751
|
fetch_url_whitelist=fetch_url_whitelist,
|
|
730
752
|
domain_cfg=domain_cfg,
|
|
731
753
|
transform_args=transform_args,
|
|
754
|
+
generated_provenance_classes=generated_provenance_classes,
|
|
732
755
|
))
|
|
733
756
|
except MissingContextException as e:
|
|
734
757
|
if skip_on_missing_context or batch:
|
|
@@ -751,6 +774,7 @@ def process(input_files: str | Path | Sequence[str | Path],
|
|
|
751
774
|
fetch_url_whitelist=fetch_url_whitelist,
|
|
752
775
|
domain_cfg=domain_cfg,
|
|
753
776
|
transform_args=transform_args,
|
|
777
|
+
generated_provenance_classes=generated_provenance_classes,
|
|
754
778
|
))
|
|
755
779
|
except Exception as e:
|
|
756
780
|
if skip_on_missing_context:
|
|
@@ -879,6 +903,18 @@ def _process_cmdln():
|
|
|
879
903
|
help='Regular expression to filter input filenames',
|
|
880
904
|
)
|
|
881
905
|
|
|
906
|
+
parser.add_argument(
|
|
907
|
+
'--generated-provenance-classes',
|
|
908
|
+
nargs='*',
|
|
909
|
+
help='Classes whose subjects will be included in the "generated" provenance metadata',
|
|
910
|
+
)
|
|
911
|
+
|
|
912
|
+
parser.add_argument(
|
|
913
|
+
'--all-subjects-provenance',
|
|
914
|
+
action='store_true',
|
|
915
|
+
help='Add all subjects in the resulting graph to the "generated" provenance metadata',
|
|
916
|
+
)
|
|
917
|
+
|
|
882
918
|
args = parser.parse_args()
|
|
883
919
|
|
|
884
920
|
if args.domain_config:
|
|
@@ -904,6 +940,12 @@ def _process_cmdln():
|
|
|
904
940
|
if args.transform_arg:
|
|
905
941
|
transform_args = dict((e.split('=', 1) for e in args.transform_arg))
|
|
906
942
|
|
|
943
|
+
generated_provenance_classes = False
|
|
944
|
+
if args.all_subjects_provenance:
|
|
945
|
+
generated_provenance_classes = True
|
|
946
|
+
elif args.generated_provenance_classes:
|
|
947
|
+
generated_provenance_classes = args.generated_provenance_classes
|
|
948
|
+
|
|
907
949
|
result = process(input_files,
|
|
908
950
|
context_fn=args.context,
|
|
909
951
|
domain_cfg=domain_cfg,
|
|
@@ -915,6 +957,7 @@ def _process_cmdln():
|
|
|
915
957
|
fetch_url_whitelist=args.url_whitelist,
|
|
916
958
|
transform_args=transform_args,
|
|
917
959
|
file_filter=args.file_filter,
|
|
960
|
+
generated_provenance_classes=generated_provenance_classes,
|
|
918
961
|
)
|
|
919
962
|
|
|
920
963
|
if args.fs:
|
|
@@ -4,7 +4,7 @@ import mimetypes
|
|
|
4
4
|
from dataclasses import dataclass
|
|
5
5
|
from datetime import datetime
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from typing import Union, Optional, Sequence
|
|
7
|
+
from typing import Union, Optional, Sequence, Iterable
|
|
8
8
|
|
|
9
9
|
from rdflib.term import Node
|
|
10
10
|
|
|
@@ -40,6 +40,22 @@ class ProvenanceMetadata:
|
|
|
40
40
|
activity_label: str = None
|
|
41
41
|
comment: str = None
|
|
42
42
|
|
|
43
|
+
def _add_list(self, attr: str, item: FileProvenanceMetadata | Iterable[FileProvenanceMetadata]):
|
|
44
|
+
items = [item] if isinstance(item, FileProvenanceMetadata) else [*item]
|
|
45
|
+
cur: FileProvenanceMetadata | list[FileProvenanceMetadata] | None = getattr(self, attr, None)
|
|
46
|
+
if not cur:
|
|
47
|
+
setattr(self, attr, items)
|
|
48
|
+
elif isinstance(cur, FileProvenanceMetadata):
|
|
49
|
+
setattr(self, attr, [self.used, *items])
|
|
50
|
+
else:
|
|
51
|
+
setattr(self, attr, cur + items)
|
|
52
|
+
|
|
53
|
+
def add_used(self, used: FileProvenanceMetadata | Iterable[FileProvenanceMetadata]) -> None:
|
|
54
|
+
self._add_list('used', used)
|
|
55
|
+
|
|
56
|
+
def add_generated(self, generated: FileProvenanceMetadata | Iterable[FileProvenanceMetadata]) -> None:
|
|
57
|
+
self._add_list('generated', generated)
|
|
58
|
+
|
|
43
59
|
|
|
44
60
|
def add_provenance_agent(g: Graph, module_name: str = None) -> Node:
|
|
45
61
|
agent = BNode()
|
|
@@ -133,7 +149,7 @@ def generate_provenance(g: Graph = None,
|
|
|
133
149
|
g.add((activity, PROV.used, used))
|
|
134
150
|
|
|
135
151
|
if metadata.generated:
|
|
136
|
-
for generated in metadata.
|
|
152
|
+
for generated in metadata.generated if isinstance(metadata.generated, Sequence) else (metadata.generated,):
|
|
137
153
|
generated = add_provenance_entity(g, metadata=generated,
|
|
138
154
|
root_directory=metadata.root_directory,
|
|
139
155
|
base_uri=metadata.base_uri)
|
|
@@ -40,6 +40,7 @@ from rdflib import Graph, RDF, SKOS, URIRef
|
|
|
40
40
|
|
|
41
41
|
from ogc.na import util
|
|
42
42
|
from ogc.na.domain_config import DomainConfiguration, DomainConfigurationEntry
|
|
43
|
+
from ogc.na.profile import ProfileRegistry
|
|
43
44
|
from ogc.na.provenance import generate_provenance, ProvenanceMetadata, FileProvenanceMetadata
|
|
44
45
|
|
|
45
46
|
logger = logging.getLogger('ogc.na.update_vocabs')
|
|
@@ -245,6 +246,7 @@ def _main():
|
|
|
245
246
|
|
|
246
247
|
parser.add_argument(
|
|
247
248
|
"domain_cfg",
|
|
249
|
+
nargs="?",
|
|
248
250
|
metavar="domain-cfg",
|
|
249
251
|
help=("Domain configuration (can be a local or remote RDF file, "
|
|
250
252
|
"or a SPARQL endpoint in the form 'sparql:http://example.org/sparql')"),
|
|
@@ -362,6 +364,17 @@ def _main():
|
|
|
362
364
|
help='Ignore errors when retrieving profile artifacts'
|
|
363
365
|
)
|
|
364
366
|
|
|
367
|
+
parser.add_argument(
|
|
368
|
+
'--graph-uri',
|
|
369
|
+
help='Override graph URI that will be used for all resources',
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
parser.add_argument(
|
|
373
|
+
'--profile-uris',
|
|
374
|
+
nargs='*',
|
|
375
|
+
help='Override profile URIs that will be used for all resources',
|
|
376
|
+
)
|
|
377
|
+
|
|
365
378
|
args = parser.parse_args()
|
|
366
379
|
|
|
367
380
|
setup_logging(args.debug)
|
|
@@ -410,29 +423,52 @@ def _main():
|
|
|
410
423
|
raise Exception(f"Invalid local artifact mapping: {mappingstr}")
|
|
411
424
|
local_artifacts_mappings[mapping[0]] = mapping[1]
|
|
412
425
|
|
|
413
|
-
domain_cfg
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
426
|
+
if not args.domain_cfg and not (args.profile_source and args.profile_uris):
|
|
427
|
+
logger.error('Either a domain configuration or a profile source and a set of '
|
|
428
|
+
'profile URIs need to be provided')
|
|
429
|
+
sys.exit(2)
|
|
430
|
+
|
|
431
|
+
modified: dict[Path, DomainConfigurationEntry | None]
|
|
432
|
+
added: dict[Path, DomainConfigurationEntry | None]
|
|
433
|
+
|
|
434
|
+
if args.domain_cfg:
|
|
435
|
+
domain_cfg = DomainConfiguration(args.domain_cfg, working_directory=args.working_directory,
|
|
436
|
+
profile_sources=args.profile_source,
|
|
437
|
+
ignore_artifact_errors=args.ignore_artifact_errors,
|
|
438
|
+
local_artifacts_mappings=local_artifacts_mappings)
|
|
439
|
+
cfg_entries = domain_cfg.entries
|
|
440
|
+
if not len(cfg_entries):
|
|
441
|
+
if args.domain:
|
|
442
|
+
logger.warning('No configuration found in %s for domain %s, exiting',
|
|
443
|
+
args.domain_cfg, args.domain)
|
|
444
|
+
else:
|
|
445
|
+
logger.warning('No configuration found in %s exiting', args.domain_cfg)
|
|
446
|
+
sys.exit(1)
|
|
447
|
+
|
|
448
|
+
profile_registry = domain_cfg.profile_registry
|
|
449
|
+
|
|
450
|
+
if args.batch:
|
|
451
|
+
modified = cfg_entries.find_all()
|
|
452
|
+
added = {}
|
|
422
453
|
else:
|
|
423
|
-
|
|
424
|
-
|
|
454
|
+
modified = cfg_entries.find_entries_for_files(mod_list)
|
|
455
|
+
added = cfg_entries.find_entries_for_files(add_list)
|
|
425
456
|
|
|
426
|
-
|
|
457
|
+
root_directory = domain_cfg.working_directory
|
|
427
458
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
modified = cfg_entries.find_all()
|
|
432
|
-
added = {}
|
|
459
|
+
elif args.batch:
|
|
460
|
+
logger.error('--batch requires a domain configuration')
|
|
461
|
+
sys.exit(3)
|
|
433
462
|
else:
|
|
434
|
-
|
|
435
|
-
|
|
463
|
+
logger.info('Loading profile sources and URIs from script parameters')
|
|
464
|
+
profile_registry = ProfileRegistry(args.profile_source,
|
|
465
|
+
ignore_artifact_errors=args.ignore_artifact_errors,
|
|
466
|
+
local_artifact_mappings=args.local_artifact_mappings)
|
|
467
|
+
|
|
468
|
+
modified = {Path(x): None for x in mod_list}
|
|
469
|
+
added = {Path(x): None for x in add_list}
|
|
470
|
+
|
|
471
|
+
root_directory = Path(args.working_directory or os.getcwd())
|
|
436
472
|
|
|
437
473
|
output_path = Path(args.output_directory) if args.output_directory else None
|
|
438
474
|
|
|
@@ -448,21 +484,28 @@ def _main():
|
|
|
448
484
|
if args.no_provenance:
|
|
449
485
|
provenance_metadata = None
|
|
450
486
|
else:
|
|
487
|
+
used = [FileProvenanceMetadata(filename=doc)]
|
|
488
|
+
if args.domain_cfg:
|
|
489
|
+
used.append(FileProvenanceMetadata(filename=args.domain_cfg))
|
|
451
490
|
provenance_metadata = ProvenanceMetadata(
|
|
452
|
-
used=
|
|
453
|
-
FileProvenanceMetadata(filename=args.domain_cfg)],
|
|
491
|
+
used=used,
|
|
454
492
|
start=datetime.now(),
|
|
455
493
|
end_auto=True,
|
|
456
|
-
root_directory=
|
|
494
|
+
root_directory=root_directory,
|
|
457
495
|
batch_activity_id=activity_id,
|
|
458
496
|
activity_label='Entailment and validation',
|
|
459
497
|
comment=cmdline,
|
|
460
498
|
base_uri=args.base_uri,
|
|
461
499
|
)
|
|
462
500
|
|
|
501
|
+
if cfg:
|
|
502
|
+
conforms_to = cfg.conforms_to
|
|
503
|
+
else:
|
|
504
|
+
conforms_to = args.profile_uris
|
|
505
|
+
|
|
463
506
|
origg = Graph().parse(doc)
|
|
464
|
-
newg, entail_artifacts = profile_registry.entail(origg,
|
|
465
|
-
validation_result = profile_registry.validate(newg,
|
|
507
|
+
newg, entail_artifacts = profile_registry.entail(origg, conforms_to)
|
|
508
|
+
validation_result = profile_registry.validate(newg, conforms_to, log_artifact_errors=True)
|
|
466
509
|
|
|
467
510
|
if provenance_metadata:
|
|
468
511
|
def add_artifact(a: Union[str, Path]):
|
|
@@ -482,7 +525,7 @@ def _main():
|
|
|
482
525
|
else:
|
|
483
526
|
entailment_dir = DEFAULT_ENTAILED_DIR
|
|
484
527
|
|
|
485
|
-
loadable_path = make_rdf(doc, newg, cfg.uri_root_filter,
|
|
528
|
+
loadable_path = make_rdf(doc, newg, cfg.uri_root_filter if cfg else None,
|
|
486
529
|
entailment_dir, provenance_metadata)
|
|
487
530
|
with open(loadable_path.with_suffix('.txt'), 'w') as validation_file:
|
|
488
531
|
validation_file.write(validation_result.text)
|
|
@@ -495,13 +538,20 @@ def _main():
|
|
|
495
538
|
if p != loadable_path:
|
|
496
539
|
loadables[p] = g
|
|
497
540
|
|
|
498
|
-
|
|
541
|
+
if args.graph_uri:
|
|
542
|
+
graphname = args.graph_uri
|
|
543
|
+
else:
|
|
544
|
+
graphname = next(get_graph_uri_for_vocab(newg), None)
|
|
545
|
+
|
|
499
546
|
if not graphname:
|
|
500
547
|
logger.warning("No graph name could be deduced from the vocabulary")
|
|
501
548
|
# Create graph name from a colon-separated list of
|
|
502
549
|
# path components relative to the working directory
|
|
503
|
-
|
|
504
|
-
|
|
550
|
+
urnparts = ['x-urn', 'ogc', 'na']
|
|
551
|
+
if cfg and cfg.identifier:
|
|
552
|
+
urnparts.append(str(cfg.identifier))
|
|
553
|
+
urnparts.extend(p for p in docrelpath.parts if p and p != '..')
|
|
554
|
+
graphname = ':'.join(urnparts)
|
|
505
555
|
append_data = graphname in uploaded_graphs
|
|
506
556
|
logger.info("Using graph name %s for %s", graphname, str(doc))
|
|
507
557
|
|
|
@@ -523,7 +573,7 @@ def _main():
|
|
|
523
573
|
raise e
|
|
524
574
|
versioned_gname = f'{graphname}{n + 1}'
|
|
525
575
|
|
|
526
|
-
report.setdefault(cfg.identifier, {}) \
|
|
576
|
+
report.setdefault(cfg.identifier if cfg else args.graph_uri, {}) \
|
|
527
577
|
.setdefault(report_cat, []).append(os.path.relpath(doc))
|
|
528
578
|
|
|
529
579
|
for scope, scopereport in report.items():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: ogc_na
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: OGC Naming Authority tools
|
|
5
5
|
Author-email: Rob Atkinson <ratkinson@ogc.org>, Piotr Zaborowski <pzaborowski@ogc.org>, Alejandro Villar <avillar@ogc.org>
|
|
6
6
|
Project-URL: Homepage, https://github.com/opengeospatial/ogc-na-tools/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|