ogc-na 0.3.47__py3-none-any.whl → 0.3.49__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.
Potentially problematic release.
This version of ogc-na might be problematic. Click here for more details.
- ogc/na/_version.py +2 -2
- ogc/na/annotate_schema.py +29 -23
- ogc/na/util.py +3 -0
- {ogc_na-0.3.47.dist-info → ogc_na-0.3.49.dist-info}/METADATA +1 -1
- {ogc_na-0.3.47.dist-info → ogc_na-0.3.49.dist-info}/RECORD +7 -7
- {ogc_na-0.3.47.dist-info → ogc_na-0.3.49.dist-info}/WHEEL +1 -1
- {ogc_na-0.3.47.dist-info → ogc_na-0.3.49.dist-info}/top_level.txt +0 -0
ogc/na/_version.py
CHANGED
ogc/na/annotate_schema.py
CHANGED
|
@@ -117,6 +117,7 @@ from __future__ import annotations
|
|
|
117
117
|
|
|
118
118
|
import argparse
|
|
119
119
|
import csv
|
|
120
|
+
import copy
|
|
120
121
|
import dataclasses
|
|
121
122
|
import json
|
|
122
123
|
import logging
|
|
@@ -723,24 +724,29 @@ class ContextBuilder:
|
|
|
723
724
|
self.visited_properties[full_property_path_str] = prop_context['@id']
|
|
724
725
|
self._missed_properties[full_property_path_str] = False
|
|
725
726
|
if prop_context['@id'] == '@nest':
|
|
726
|
-
process_subschema(prop_val, from_schema,
|
|
727
|
+
merge_contexts(onto_context, process_subschema(prop_val, from_schema, full_property_path))
|
|
727
728
|
else:
|
|
728
|
-
|
|
729
|
+
merge_contexts(prop_context['@context'],
|
|
730
|
+
process_subschema(prop_val, from_schema, full_property_path))
|
|
729
731
|
if prop not in onto_context or isinstance(onto_context[prop], str):
|
|
730
732
|
onto_context[prop] = prop_context
|
|
731
733
|
else:
|
|
732
734
|
merge_contexts(onto_context[prop], prop_context)
|
|
733
735
|
else:
|
|
734
|
-
process_subschema(prop_val, from_schema,
|
|
736
|
+
merge_contexts(onto_context, process_subschema(prop_val, from_schema, full_property_path))
|
|
735
737
|
|
|
736
738
|
imported_prefixes: dict[str | Path, dict[str, str]] = {}
|
|
737
739
|
imported_extra_terms: dict[str | Path, dict[str, str]] = {}
|
|
738
740
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
+
cached_schema_contexts = {}
|
|
742
|
+
|
|
743
|
+
def process_subschema(subschema: dict, from_schema: ReferencedSchema,
|
|
744
|
+
schema_path: list[str]) -> dict:
|
|
745
|
+
|
|
746
|
+
onto_context = {}
|
|
741
747
|
|
|
742
748
|
if not isinstance(subschema, dict):
|
|
743
|
-
return
|
|
749
|
+
return {}
|
|
744
750
|
|
|
745
751
|
if subschema.get(ANNOTATION_BASE):
|
|
746
752
|
onto_context['@base'] = subschema[ANNOTATION_BASE]
|
|
@@ -753,33 +759,25 @@ class ContextBuilder:
|
|
|
753
759
|
processed_refs.add(ref_path_str)
|
|
754
760
|
referenced_schema = self.schema_resolver.resolve_schema(ref, from_schema)
|
|
755
761
|
if referenced_schema:
|
|
756
|
-
|
|
757
|
-
|
|
762
|
+
ref_ctx = copy.deepcopy(cached_schema_contexts.get(ref_path_str))
|
|
763
|
+
if ref_ctx is None:
|
|
764
|
+
ref_ctx = process_subschema(referenced_schema.subschema, referenced_schema, schema_path)
|
|
765
|
+
merge_contexts(onto_context, ref_ctx)
|
|
758
766
|
|
|
759
767
|
for i in ('allOf', 'anyOf', 'oneOf'):
|
|
760
768
|
l = subschema.get(i)
|
|
761
769
|
if isinstance(l, list):
|
|
762
770
|
for idx, sub_subschema in enumerate(l):
|
|
763
|
-
process_subschema(sub_subschema, from_schema,
|
|
764
|
-
schema_path)
|
|
771
|
+
merge_contexts(onto_context, process_subschema(sub_subschema, from_schema, schema_path))
|
|
765
772
|
|
|
766
773
|
for i in ('prefixItems', 'items', 'contains', 'then', 'else', 'additionalProperties'):
|
|
767
774
|
l = subschema.get(i)
|
|
768
775
|
if isinstance(l, dict):
|
|
769
|
-
process_subschema(l, from_schema,
|
|
776
|
+
merge_contexts(onto_context, process_subschema(l, from_schema, schema_path))
|
|
770
777
|
|
|
771
778
|
for pp_k, pp in subschema.get('patternProperties', {}).items():
|
|
772
779
|
if isinstance(pp, dict):
|
|
773
|
-
process_subschema(pp, from_schema,
|
|
774
|
-
|
|
775
|
-
for p in ('definitions', '$defs'):
|
|
776
|
-
defs = subschema.get(p)
|
|
777
|
-
if defs and isinstance(defs, dict):
|
|
778
|
-
for entry_key, entry in defs.items():
|
|
779
|
-
def_path = schema_path + [entry_key]
|
|
780
|
-
def_path_str = f"{from_schema.location}#{'/'.join(def_path)}"
|
|
781
|
-
if def_path_str not in processed_refs:
|
|
782
|
-
process_subschema(entry, from_schema, onto_context, def_path)
|
|
780
|
+
merge_contexts(onto_context, process_subschema(pp, from_schema, schema_path + [pp_k]))
|
|
783
781
|
|
|
784
782
|
if ANNOTATION_EXTRA_TERMS in subschema:
|
|
785
783
|
for extra_term, extra_term_context in subschema[ANNOTATION_EXTRA_TERMS].items():
|
|
@@ -806,7 +804,10 @@ class ContextBuilder:
|
|
|
806
804
|
if isinstance(sub_prefixes, dict):
|
|
807
805
|
prefixes.update({k: v for k, v in sub_prefixes.items() if k not in prefixes})
|
|
808
806
|
|
|
809
|
-
|
|
807
|
+
cached_schema_contexts[f"{from_schema.location}#{from_schema.fragment}"] = onto_context
|
|
808
|
+
return onto_context
|
|
809
|
+
|
|
810
|
+
merge_contexts(own_context, process_subschema(root_schema.subschema, root_schema, []))
|
|
810
811
|
|
|
811
812
|
for imported_et in imported_extra_terms.values():
|
|
812
813
|
for term, v in imported_et.items():
|
|
@@ -853,10 +854,13 @@ class ContextBuilder:
|
|
|
853
854
|
if isinstance(term_value, dict) and '@context' in term_value:
|
|
854
855
|
if not term_value['@context']:
|
|
855
856
|
del term_value['@context']
|
|
857
|
+
changed = True
|
|
856
858
|
else:
|
|
857
859
|
while True:
|
|
858
860
|
if not compact_branch(term_value['@context'], child_context_stack):
|
|
859
861
|
break
|
|
862
|
+
else:
|
|
863
|
+
changed = True
|
|
860
864
|
|
|
861
865
|
if context_stack:
|
|
862
866
|
for ctx in context_stack:
|
|
@@ -890,7 +894,9 @@ class ContextBuilder:
|
|
|
890
894
|
elif '@context' in term_value:
|
|
891
895
|
compact_uris(term_value['@context'], child_context_stack)
|
|
892
896
|
|
|
893
|
-
|
|
897
|
+
while True:
|
|
898
|
+
if not compact_branch(own_context):
|
|
899
|
+
break
|
|
894
900
|
compact_uris(own_context)
|
|
895
901
|
|
|
896
902
|
self._parsed_schemas[schema_location] = own_context
|
ogc/na/util.py
CHANGED
|
@@ -310,6 +310,9 @@ def git_status(repo_path: str | Path = '.'):
|
|
|
310
310
|
|
|
311
311
|
|
|
312
312
|
def merge_contexts(a: dict, b: dict, fix_nest=True) -> dict[str, Any]:
|
|
313
|
+
'''
|
|
314
|
+
Merges two JSON-lD contexts, updating the first one passed to this function (and returning it).
|
|
315
|
+
'''
|
|
313
316
|
if not b:
|
|
314
317
|
return a
|
|
315
318
|
if not a:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ogc_na
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.49
|
|
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,6 +1,6 @@
|
|
|
1
1
|
ogc/na/__init__.py,sha256=uzcNiJ3uKFNJ1HBfKxIwgAy2HMUFsLAe5RkrUg8ncac,464
|
|
2
|
-
ogc/na/_version.py,sha256=
|
|
3
|
-
ogc/na/annotate_schema.py,sha256=
|
|
2
|
+
ogc/na/_version.py,sha256=TsNmNGuKIPd5pF6DeDUV5CEoCXDMqjLzL1EZreVDEAw,413
|
|
3
|
+
ogc/na/annotate_schema.py,sha256=SdaZYNooPeaomLTzOvMIhHs8LLUfOj7hZnNEM_IknT8,41187
|
|
4
4
|
ogc/na/domain_config.py,sha256=ORzITa1rTrD1MQdpWYrIVW5SwSa9lJd3hnyHIxNgiIU,13947
|
|
5
5
|
ogc/na/download.py,sha256=2afrLyl4WsAlxkCgXsl47fs9mNKfDmhVpeT2iwNSoq0,3354
|
|
6
6
|
ogc/na/gsp.py,sha256=KGa2G9i8kPefYTHNPUDoXnNyF7Tiwt8K__Ew_Qa7eeg,6048
|
|
@@ -9,12 +9,12 @@ ogc/na/models.py,sha256=nGV8EALtXvmBtkUbu0FA4KOgwNUqQGWIDuMo7UGOKP8,652
|
|
|
9
9
|
ogc/na/profile.py,sha256=T7nesbm7azF2ijF60UenJnQQKjIgJlnJ3pUbGT5nYgM,16511
|
|
10
10
|
ogc/na/provenance.py,sha256=h7UtUb1wW_9MfEim0fjcqkHd0BYmpXqyE1ADzL9AH7I,5551
|
|
11
11
|
ogc/na/update_vocabs.py,sha256=joLZxhpBJja5GvaBnt0aHQStKETOCIh5PotUxmJsOHs,18180
|
|
12
|
-
ogc/na/util.py,sha256=
|
|
12
|
+
ogc/na/util.py,sha256=Ztju3g1YuguUDbk4n2RJfCrl_IIzNAj7linfy24T6VA,12067
|
|
13
13
|
ogc/na/validation.py,sha256=5xjHH55NZKM8HtUk8XgVzm8W5ZlZY00u_qsWfXK_8dM,3732
|
|
14
14
|
ogc/na/input_filters/__init__.py,sha256=AhE7n_yECwxFKwOM3Jc0ft96TtF5i_Z-fHrS4HYOjaE,1179
|
|
15
15
|
ogc/na/input_filters/csv.py,sha256=nFfB1XQF_QApcGGzMqEvzD_b3pBtCtsfUECsZ9UGE6s,2616
|
|
16
16
|
ogc/na/input_filters/xml.py,sha256=9qYjp_w5JLInFM48zB15IYH9eTafjp1Aqd_8kfuW3aA,2074
|
|
17
|
-
ogc_na-0.3.
|
|
18
|
-
ogc_na-0.3.
|
|
19
|
-
ogc_na-0.3.
|
|
20
|
-
ogc_na-0.3.
|
|
17
|
+
ogc_na-0.3.49.dist-info/METADATA,sha256=utM52i7eBc66GDtIj58CbYtQiOyUUF_QECuBGcD5ZXo,3829
|
|
18
|
+
ogc_na-0.3.49.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
|
19
|
+
ogc_na-0.3.49.dist-info/top_level.txt,sha256=Kvy3KhzcIhNPT4_nZuJCmS946ptRr_MDyU4IIhZJhCY,4
|
|
20
|
+
ogc_na-0.3.49.dist-info/RECORD,,
|
|
File without changes
|