ogc-na 0.3.45__tar.gz → 0.3.46__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.45 → ogc_na-0.3.46}/PKG-INFO +2 -1
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/_version.py +2 -2
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/annotate_schema.py +20 -25
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/PKG-INFO +2 -1
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/requires.txt +1 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/requirements.txt +1 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/.github/workflows/mkdocs.yml +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/.github/workflows/python-publish.yml +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/.gitignore +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/MANIFEST.in +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/README.md +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/examples.md +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/gen_ref_pages.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/index.md +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/jsonld-uplift.md +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/tutorials.md +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/mkdocs.yml +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/__init__.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/domain_config.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/download.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/gsp.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/ingest_json.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/input_filters/__init__.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/input_filters/csv.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/input_filters/xml.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/models.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/profile.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/provenance.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/update_vocabs.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/util.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/validation.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/SOURCES.txt +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/dependency_links.txt +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/top_level.txt +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/pyproject.toml +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/rdf/catalog-v001.xml +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/rdf/domaincfg.vocab.ttl +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/setup.cfg +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/setup.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/__init__.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/empty.ttl +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/headers.csv +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/no-headers.csv +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/profile_tree.ttl +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/profile_tree_cyclic.ttl +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/sample-context.jsonld +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/sample-schema-prop-c.yml +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/sample-schema.yml +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/schema-vocab.yml +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/uplift_context_valid.yml +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/test_annotate_schema.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/test_ingest_json.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/test_input_filters_csv.py +0 -0
- {ogc_na-0.3.45 → ogc_na-0.3.46}/test/test_profile.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ogc_na
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.46
|
|
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/
|
|
@@ -26,6 +26,7 @@ Requires-Dist: GitPython>=3.1.32
|
|
|
26
26
|
Requires-Dist: rfc3987
|
|
27
27
|
Requires-Dist: requests-cache
|
|
28
28
|
Requires-Dist: xmltodict
|
|
29
|
+
Requires-Dist: jsonpointer~=2.4
|
|
29
30
|
Requires-Dist: setuptools
|
|
30
31
|
Provides-Extra: dev
|
|
31
32
|
Requires-Dist: mkdocs>=1.4.2; extra == "dev"
|
|
@@ -127,6 +127,7 @@ from pathlib import Path
|
|
|
127
127
|
from typing import Any, AnyStr, Callable, Sequence, Iterable
|
|
128
128
|
from urllib.parse import urlparse, urljoin
|
|
129
129
|
|
|
130
|
+
import jsonpointer
|
|
130
131
|
import jsonschema
|
|
131
132
|
import requests_cache
|
|
132
133
|
|
|
@@ -180,26 +181,21 @@ class SchemaResolver:
|
|
|
180
181
|
|
|
181
182
|
def __init__(self, working_directory=Path()):
|
|
182
183
|
self.working_directory = working_directory.resolve()
|
|
183
|
-
self._schema_cache: dict[str | Path,
|
|
184
|
+
self._schema_cache: dict[str | Path, Any] = {}
|
|
184
185
|
|
|
185
186
|
@staticmethod
|
|
186
187
|
def _get_branch(schema: dict, ref: str):
|
|
187
|
-
|
|
188
|
-
pointer = schema
|
|
189
|
-
for item in path:
|
|
190
|
-
if item:
|
|
191
|
-
pointer = pointer[item]
|
|
192
|
-
return pointer
|
|
188
|
+
return jsonpointer.resolve_pointer(schema, re.sub('^#', '', ref))
|
|
193
189
|
|
|
194
190
|
def load_contents(self, s: str | Path) -> tuple[dict, bool]:
|
|
195
191
|
"""
|
|
196
192
|
Load the contents of a schema. Can be overriden by subclasses to alter the loading process.
|
|
197
193
|
"""
|
|
198
|
-
contents
|
|
194
|
+
contents = self._schema_cache.get(s)
|
|
199
195
|
if contents is None:
|
|
200
|
-
contents
|
|
201
|
-
self._schema_cache[s] = contents
|
|
202
|
-
return contents
|
|
196
|
+
contents = read_contents(s)[0]
|
|
197
|
+
self._schema_cache[s] = contents
|
|
198
|
+
return load_json_yaml(contents)
|
|
203
199
|
|
|
204
200
|
def resolve_ref(self, ref: str | Path, from_schema: ReferencedSchema | None = None) -> tuple[Path | str, str]:
|
|
205
201
|
location = ref
|
|
@@ -230,7 +226,8 @@ class SchemaResolver:
|
|
|
230
226
|
|
|
231
227
|
return location, fragment
|
|
232
228
|
|
|
233
|
-
def resolve_schema(self, ref: str | Path, from_schema: ReferencedSchema | None = None
|
|
229
|
+
def resolve_schema(self, ref: str | Path, from_schema: ReferencedSchema | None = None,
|
|
230
|
+
force_contents: dict | None = None) -> ReferencedSchema | None:
|
|
234
231
|
chain = from_schema.chain + [from_schema] if from_schema else []
|
|
235
232
|
try:
|
|
236
233
|
schema_source, fragment = self.resolve_ref(ref, from_schema)
|
|
@@ -251,6 +248,8 @@ class SchemaResolver:
|
|
|
251
248
|
is_json=from_schema.is_json)
|
|
252
249
|
|
|
253
250
|
contents, is_json = self.load_contents(schema_source)
|
|
251
|
+
if force_contents:
|
|
252
|
+
contents = force_contents
|
|
254
253
|
if fragment:
|
|
255
254
|
return ReferencedSchema(location=schema_source, fragment=fragment,
|
|
256
255
|
subschema=SchemaResolver._get_branch(contents, fragment),
|
|
@@ -457,12 +456,8 @@ class SchemaAnnotator:
|
|
|
457
456
|
def process_schema(self, location: Path | str | None,
|
|
458
457
|
default_context: str | Path | dict | None = None,
|
|
459
458
|
contents: dict | None = None) -> AnnotatedSchema | None:
|
|
460
|
-
resolved_schema = self.schema_resolver.resolve_schema(location)
|
|
461
|
-
|
|
462
|
-
# overriden
|
|
463
|
-
schema = contents
|
|
464
|
-
else:
|
|
465
|
-
schema = resolved_schema.subschema
|
|
459
|
+
resolved_schema = self.schema_resolver.resolve_schema(location, force_contents=contents)
|
|
460
|
+
schema = resolved_schema.subschema
|
|
466
461
|
|
|
467
462
|
if all(x not in schema for x in ('schema', 'openapi')):
|
|
468
463
|
validate_schema(schema)
|
|
@@ -568,6 +563,13 @@ class SchemaAnnotator:
|
|
|
568
563
|
|
|
569
564
|
used_terms = set()
|
|
570
565
|
|
|
566
|
+
# Annotate definitions and $defs - can later be overridden if referenced from a different path
|
|
567
|
+
for p in ('definitions', '$defs'):
|
|
568
|
+
defs = subschema.get(p)
|
|
569
|
+
if defs and isinstance(defs, dict):
|
|
570
|
+
for entry in defs.values():
|
|
571
|
+
used_terms.update(process_subschema(entry, context_stack, from_schema, level + 1))
|
|
572
|
+
|
|
571
573
|
if '$ref' in subschema and id(subschema) not in updated_refs:
|
|
572
574
|
if self._ref_mapper:
|
|
573
575
|
subschema['$ref'] = self._ref_mapper(subschema['$ref'], subschema)
|
|
@@ -585,13 +587,6 @@ class SchemaAnnotator:
|
|
|
585
587
|
for entry in collection:
|
|
586
588
|
used_terms.update(process_subschema(entry, context_stack, from_schema, level + 1))
|
|
587
589
|
|
|
588
|
-
# Annotate definitions and $defs
|
|
589
|
-
for p in ('definitions', '$defs'):
|
|
590
|
-
defs = subschema.get(p)
|
|
591
|
-
if defs and isinstance(defs, dict):
|
|
592
|
-
for entry in defs.values():
|
|
593
|
-
used_terms.update(process_subschema(entry, context_stack, from_schema, level + 1))
|
|
594
|
-
|
|
595
590
|
for p in ('then', 'else', 'additionalProperties'):
|
|
596
591
|
branch = subschema.get(p)
|
|
597
592
|
if branch and isinstance(branch, dict):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ogc_na
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.46
|
|
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/
|
|
@@ -26,6 +26,7 @@ Requires-Dist: GitPython>=3.1.32
|
|
|
26
26
|
Requires-Dist: rfc3987
|
|
27
27
|
Requires-Dist: requests-cache
|
|
28
28
|
Requires-Dist: xmltodict
|
|
29
|
+
Requires-Dist: jsonpointer~=2.4
|
|
29
30
|
Requires-Dist: setuptools
|
|
30
31
|
Provides-Extra: dev
|
|
31
32
|
Requires-Dist: mkdocs>=1.4.2; extra == "dev"
|
|
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
|