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.

Files changed (54) hide show
  1. {ogc_na-0.3.45 → ogc_na-0.3.46}/PKG-INFO +2 -1
  2. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/_version.py +2 -2
  3. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/annotate_schema.py +20 -25
  4. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/PKG-INFO +2 -1
  5. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/requires.txt +1 -0
  6. {ogc_na-0.3.45 → ogc_na-0.3.46}/requirements.txt +1 -0
  7. {ogc_na-0.3.45 → ogc_na-0.3.46}/.github/workflows/mkdocs.yml +0 -0
  8. {ogc_na-0.3.45 → ogc_na-0.3.46}/.github/workflows/python-publish.yml +0 -0
  9. {ogc_na-0.3.45 → ogc_na-0.3.46}/.gitignore +0 -0
  10. {ogc_na-0.3.45 → ogc_na-0.3.46}/MANIFEST.in +0 -0
  11. {ogc_na-0.3.45 → ogc_na-0.3.46}/README.md +0 -0
  12. {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/examples.md +0 -0
  13. {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/gen_ref_pages.py +0 -0
  14. {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/index.md +0 -0
  15. {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/jsonld-uplift.md +0 -0
  16. {ogc_na-0.3.45 → ogc_na-0.3.46}/docs/tutorials.md +0 -0
  17. {ogc_na-0.3.45 → ogc_na-0.3.46}/mkdocs.yml +0 -0
  18. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/__init__.py +0 -0
  19. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/domain_config.py +0 -0
  20. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/download.py +0 -0
  21. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/gsp.py +0 -0
  22. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/ingest_json.py +0 -0
  23. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/input_filters/__init__.py +0 -0
  24. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/input_filters/csv.py +0 -0
  25. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/input_filters/xml.py +0 -0
  26. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/models.py +0 -0
  27. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/profile.py +0 -0
  28. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/provenance.py +0 -0
  29. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/update_vocabs.py +0 -0
  30. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/util.py +0 -0
  31. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc/na/validation.py +0 -0
  32. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/SOURCES.txt +0 -0
  33. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/dependency_links.txt +0 -0
  34. {ogc_na-0.3.45 → ogc_na-0.3.46}/ogc_na.egg-info/top_level.txt +0 -0
  35. {ogc_na-0.3.45 → ogc_na-0.3.46}/pyproject.toml +0 -0
  36. {ogc_na-0.3.45 → ogc_na-0.3.46}/rdf/catalog-v001.xml +0 -0
  37. {ogc_na-0.3.45 → ogc_na-0.3.46}/rdf/domaincfg.vocab.ttl +0 -0
  38. {ogc_na-0.3.45 → ogc_na-0.3.46}/setup.cfg +0 -0
  39. {ogc_na-0.3.45 → ogc_na-0.3.46}/setup.py +0 -0
  40. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/__init__.py +0 -0
  41. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/empty.ttl +0 -0
  42. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/headers.csv +0 -0
  43. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/no-headers.csv +0 -0
  44. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/profile_tree.ttl +0 -0
  45. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/profile_tree_cyclic.ttl +0 -0
  46. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/sample-context.jsonld +0 -0
  47. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/sample-schema-prop-c.yml +0 -0
  48. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/sample-schema.yml +0 -0
  49. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/schema-vocab.yml +0 -0
  50. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/data/uplift_context_valid.yml +0 -0
  51. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/test_annotate_schema.py +0 -0
  52. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/test_ingest_json.py +0 -0
  53. {ogc_na-0.3.45 → ogc_na-0.3.46}/test/test_input_filters_csv.py +0 -0
  54. {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.45
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"
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.3.45'
16
- __version_tuple__ = version_tuple = (0, 3, 45)
15
+ __version__ = version = '0.3.46'
16
+ __version_tuple__ = version_tuple = (0, 3, 46)
@@ -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, tuple[Any, bool]] = {}
184
+ self._schema_cache: dict[str | Path, Any] = {}
184
185
 
185
186
  @staticmethod
186
187
  def _get_branch(schema: dict, ref: str):
187
- path = re.sub(r'^#?/?', '', ref).split('/')
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, is_json = self._schema_cache.get(s, (None, False))
194
+ contents = self._schema_cache.get(s)
199
195
  if contents is None:
200
- contents, is_json = load_json_yaml(read_contents(s)[0])
201
- self._schema_cache[s] = contents, is_json
202
- return contents, is_json
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) -> ReferencedSchema | 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
- if contents:
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.45
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"
@@ -11,6 +11,7 @@ GitPython>=3.1.32
11
11
  rfc3987
12
12
  requests-cache
13
13
  xmltodict
14
+ jsonpointer~=2.4
14
15
  setuptools
15
16
 
16
17
  [dev]
@@ -11,6 +11,7 @@ GitPython>=3.1.32
11
11
  rfc3987
12
12
  requests-cache
13
13
  xmltodict
14
+ jsonpointer~=2.4
14
15
 
15
16
  # to be removed once https://github.com/RDFLib/pySHACL/issues/212 is fixed
16
17
  setuptools
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