ogc-na 0.3.48__tar.gz → 0.3.49__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.48 → ogc_na-0.3.49}/PKG-INFO +1 -1
  2. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/_version.py +2 -2
  3. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/annotate_schema.py +29 -14
  4. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/util.py +3 -0
  5. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc_na.egg-info/PKG-INFO +1 -1
  6. {ogc_na-0.3.48 → ogc_na-0.3.49}/.github/workflows/mkdocs.yml +0 -0
  7. {ogc_na-0.3.48 → ogc_na-0.3.49}/.github/workflows/python-publish.yml +0 -0
  8. {ogc_na-0.3.48 → ogc_na-0.3.49}/.gitignore +0 -0
  9. {ogc_na-0.3.48 → ogc_na-0.3.49}/MANIFEST.in +0 -0
  10. {ogc_na-0.3.48 → ogc_na-0.3.49}/README.md +0 -0
  11. {ogc_na-0.3.48 → ogc_na-0.3.49}/docs/examples.md +0 -0
  12. {ogc_na-0.3.48 → ogc_na-0.3.49}/docs/gen_ref_pages.py +0 -0
  13. {ogc_na-0.3.48 → ogc_na-0.3.49}/docs/index.md +0 -0
  14. {ogc_na-0.3.48 → ogc_na-0.3.49}/docs/jsonld-uplift.md +0 -0
  15. {ogc_na-0.3.48 → ogc_na-0.3.49}/docs/tutorials.md +0 -0
  16. {ogc_na-0.3.48 → ogc_na-0.3.49}/mkdocs.yml +0 -0
  17. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/__init__.py +0 -0
  18. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/domain_config.py +0 -0
  19. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/download.py +0 -0
  20. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/gsp.py +0 -0
  21. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/ingest_json.py +0 -0
  22. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/input_filters/__init__.py +0 -0
  23. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/input_filters/csv.py +0 -0
  24. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/input_filters/xml.py +0 -0
  25. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/models.py +0 -0
  26. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/profile.py +0 -0
  27. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/provenance.py +0 -0
  28. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/update_vocabs.py +0 -0
  29. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc/na/validation.py +0 -0
  30. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc_na.egg-info/SOURCES.txt +0 -0
  31. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc_na.egg-info/dependency_links.txt +0 -0
  32. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc_na.egg-info/requires.txt +0 -0
  33. {ogc_na-0.3.48 → ogc_na-0.3.49}/ogc_na.egg-info/top_level.txt +0 -0
  34. {ogc_na-0.3.48 → ogc_na-0.3.49}/pyproject.toml +0 -0
  35. {ogc_na-0.3.48 → ogc_na-0.3.49}/rdf/catalog-v001.xml +0 -0
  36. {ogc_na-0.3.48 → ogc_na-0.3.49}/rdf/domaincfg.vocab.ttl +0 -0
  37. {ogc_na-0.3.48 → ogc_na-0.3.49}/requirements.txt +0 -0
  38. {ogc_na-0.3.48 → ogc_na-0.3.49}/setup.cfg +0 -0
  39. {ogc_na-0.3.48 → ogc_na-0.3.49}/setup.py +0 -0
  40. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/__init__.py +0 -0
  41. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/empty.ttl +0 -0
  42. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/headers.csv +0 -0
  43. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/no-headers.csv +0 -0
  44. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/profile_tree.ttl +0 -0
  45. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/profile_tree_cyclic.ttl +0 -0
  46. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/sample-context.jsonld +0 -0
  47. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/sample-schema-prop-c.yml +0 -0
  48. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/sample-schema.yml +0 -0
  49. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/schema-vocab.yml +0 -0
  50. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/data/uplift_context_valid.yml +0 -0
  51. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/test_annotate_schema.py +0 -0
  52. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/test_ingest_json.py +0 -0
  53. {ogc_na-0.3.48 → ogc_na-0.3.49}/test/test_input_filters_csv.py +0 -0
  54. {ogc_na-0.3.48 → ogc_na-0.3.49}/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.48
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/
@@ -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.48'
16
- __version_tuple__ = version_tuple = (0, 3, 48)
15
+ __version__ = version = '0.3.49'
16
+ __version_tuple__ = version_tuple = (0, 3, 49)
@@ -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, onto_context, full_property_path)
727
+ merge_contexts(onto_context, process_subschema(prop_val, from_schema, full_property_path))
727
728
  else:
728
- process_subschema(prop_val, from_schema, prop_context['@context'], full_property_path)
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, onto_context, full_property_path)
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
- def process_subschema(subschema: dict, from_schema: ReferencedSchema, onto_context: dict,
740
- schema_path: list[str]) -> dict | None:
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 None
749
+ return {}
744
750
 
745
751
  if subschema.get(ANNOTATION_BASE):
746
752
  onto_context['@base'] = subschema[ANNOTATION_BASE]
@@ -753,24 +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
- process_subschema(referenced_schema.subschema, referenced_schema, onto_context,
757
- schema_path)
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, onto_context,
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, onto_context, schema_path)
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, onto_context, schema_path + [pp_k])
780
+ merge_contexts(onto_context, process_subschema(pp, from_schema, schema_path + [pp_k]))
774
781
 
775
782
  if ANNOTATION_EXTRA_TERMS in subschema:
776
783
  for extra_term, extra_term_context in subschema[ANNOTATION_EXTRA_TERMS].items():
@@ -797,7 +804,10 @@ class ContextBuilder:
797
804
  if isinstance(sub_prefixes, dict):
798
805
  prefixes.update({k: v for k, v in sub_prefixes.items() if k not in prefixes})
799
806
 
800
- process_subschema(root_schema.subschema, root_schema, own_context, [])
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, []))
801
811
 
802
812
  for imported_et in imported_extra_terms.values():
803
813
  for term, v in imported_et.items():
@@ -844,10 +854,13 @@ class ContextBuilder:
844
854
  if isinstance(term_value, dict) and '@context' in term_value:
845
855
  if not term_value['@context']:
846
856
  del term_value['@context']
857
+ changed = True
847
858
  else:
848
859
  while True:
849
860
  if not compact_branch(term_value['@context'], child_context_stack):
850
861
  break
862
+ else:
863
+ changed = True
851
864
 
852
865
  if context_stack:
853
866
  for ctx in context_stack:
@@ -881,7 +894,9 @@ class ContextBuilder:
881
894
  elif '@context' in term_value:
882
895
  compact_uris(term_value['@context'], child_context_stack)
883
896
 
884
- compact_branch(own_context)
897
+ while True:
898
+ if not compact_branch(own_context):
899
+ break
885
900
  compact_uris(own_context)
886
901
 
887
902
  self._parsed_schemas[schema_location] = own_context
@@ -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.48
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/
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