ogc-na 0.4.2__tar.gz → 0.4.4__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.4.2 → ogc_na-0.4.4}/PKG-INFO +1 -1
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/_version.py +3 -3
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/annotate_schema.py +23 -10
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc_na.egg-info/PKG-INFO +1 -1
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc_na.egg-info/SOURCES.txt +1 -0
- ogc_na-0.4.4/test/data/annotate-defs-schema.yml +20 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/test_annotate_schema.py +25 -6
- {ogc_na-0.4.2 → ogc_na-0.4.4}/.github/workflows/mkdocs.yml +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/.github/workflows/python-publish.yml +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/.gitignore +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/LICENSE +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/MANIFEST.in +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/README.md +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/docs/examples.md +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/docs/gen_ref_pages.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/docs/index.md +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/docs/jsonld-uplift.md +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/docs/tutorials.md +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/mkdocs.yml +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/__init__.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/domain_config.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/download.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/exceptions.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/gsp.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/ingest_json.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/input_filters/__init__.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/input_filters/csv.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/input_filters/xlsx.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/input_filters/xml.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/models.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/profile.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/provenance.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/update_vocabs.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/util.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc/na/validation.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc_na.egg-info/dependency_links.txt +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc_na.egg-info/requires.txt +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/ogc_na.egg-info/top_level.txt +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/pyproject.toml +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/rdf/catalog-v001.xml +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/rdf/domaincfg.vocab.ttl +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/requirements.txt +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/setup.cfg +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/setup.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/__init__.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/empty.ttl +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/headers.csv +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/headers.xlsx +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/no-headers.csv +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/no-headers.xlsx +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/profile_tree.ttl +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/profile_tree_cyclic.ttl +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/sample-context.jsonld +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/sample-schema-prop-c.yml +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/sample-schema.yml +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/schema-anchors.json +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/schema-vocab.yml +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/two-sheets.xlsx +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/data/uplift_context_valid.yml +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/test_ingest_json.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/test_input_filters_csv.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/test_input_filters_xlsx.py +0 -0
- {ogc_na-0.4.2 → ogc_na-0.4.4}/test/test_profile.py +0 -0
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.4.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 4,
|
|
31
|
+
__version__ = version = '0.4.4'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 4, 4)
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'ga90db81ee'
|
|
@@ -609,7 +609,8 @@ class SchemaAnnotator:
|
|
|
609
609
|
|
|
610
610
|
return used_terms
|
|
611
611
|
|
|
612
|
-
def process_subschema(subschema, context_stack, from_schema: ReferencedSchema, level=1
|
|
612
|
+
def process_subschema(subschema, context_stack, from_schema: ReferencedSchema, level=1,
|
|
613
|
+
in_defs=False) -> Iterable[str]:
|
|
613
614
|
if not subschema or not isinstance(subschema, dict):
|
|
614
615
|
return ()
|
|
615
616
|
|
|
@@ -620,7 +621,8 @@ class SchemaAnnotator:
|
|
|
620
621
|
defs = subschema.get(p)
|
|
621
622
|
if defs and isinstance(defs, dict):
|
|
622
623
|
for entry in defs.values():
|
|
623
|
-
used_terms
|
|
624
|
+
# Do not add to used_terms if only used in $defs
|
|
625
|
+
process_subschema(entry, context_stack, from_schema, level + 1, in_defs=True)
|
|
624
626
|
|
|
625
627
|
if '$ref' in subschema and id(subschema) not in updated_refs:
|
|
626
628
|
if self._ref_mapper:
|
|
@@ -628,8 +630,10 @@ class SchemaAnnotator:
|
|
|
628
630
|
if subschema['$ref'].startswith('#/') or subschema['$ref'].startswith(f"{from_schema.location}#/"):
|
|
629
631
|
target_schema = self.schema_resolver.resolve_schema(subschema['$ref'], from_schema)
|
|
630
632
|
if target_schema:
|
|
631
|
-
|
|
632
|
-
target_schema, level + 1)
|
|
633
|
+
new_terms = process_subschema(target_schema.subschema, context_stack,
|
|
634
|
+
target_schema, level + 1, in_defs=in_defs)
|
|
635
|
+
if not in_defs:
|
|
636
|
+
used_terms.update(new_terms)
|
|
633
637
|
updated_refs.add(id(subschema))
|
|
634
638
|
|
|
635
639
|
# Annotate oneOf, allOf, anyOf
|
|
@@ -637,16 +641,22 @@ class SchemaAnnotator:
|
|
|
637
641
|
collection = subschema.get(p)
|
|
638
642
|
if collection and isinstance(collection, list):
|
|
639
643
|
for entry in collection:
|
|
640
|
-
|
|
644
|
+
new_terms = process_subschema(entry, context_stack, from_schema, level + 1, in_defs=in_defs)
|
|
645
|
+
if not in_defs:
|
|
646
|
+
used_terms.update(new_terms)
|
|
641
647
|
|
|
642
648
|
for p in ('then', 'else', 'additionalProperties'):
|
|
643
649
|
branch = subschema.get(p)
|
|
644
650
|
if branch and isinstance(branch, dict):
|
|
645
|
-
|
|
651
|
+
new_terms = process_subschema(branch, context_stack, from_schema, level, in_defs=in_defs)
|
|
652
|
+
if not in_defs:
|
|
653
|
+
used_terms.update(new_terms)
|
|
646
654
|
|
|
647
655
|
for pp in subschema.get('patternProperties', {}).values():
|
|
648
656
|
if pp and isinstance(pp, dict):
|
|
649
|
-
|
|
657
|
+
new_terms = process_subschema(pp, context_stack, from_schema, level + 1, in_defs=in_defs)
|
|
658
|
+
if not in_defs:
|
|
659
|
+
used_terms.update(new_terms)
|
|
650
660
|
|
|
651
661
|
# Annotate main schema
|
|
652
662
|
schema_type = subschema.get('type')
|
|
@@ -657,7 +667,10 @@ class SchemaAnnotator:
|
|
|
657
667
|
used_terms.update(process_properties(subschema, context_stack, from_schema, level + 1))
|
|
658
668
|
elif schema_type == 'array':
|
|
659
669
|
for k in ('prefixItems', 'items', 'contains'):
|
|
660
|
-
|
|
670
|
+
new_terms = process_subschema(subschema.get(k), context_stack, from_schema, level + 1,
|
|
671
|
+
in_defs=in_defs)
|
|
672
|
+
if not in_defs:
|
|
673
|
+
used_terms.update(new_terms)
|
|
661
674
|
|
|
662
675
|
# Get prefixes
|
|
663
676
|
for p, bu in subschema.get(ANNOTATION_PREFIXES, {}).items():
|
|
@@ -811,8 +824,6 @@ class ContextBuilder:
|
|
|
811
824
|
if top_level_value:
|
|
812
825
|
onto_context[f"@{key[len(ANNOTATION_PREFIX):]}"] = top_level_value
|
|
813
826
|
|
|
814
|
-
read_properties(subschema, from_schema, onto_context, schema_path)
|
|
815
|
-
|
|
816
827
|
if '$ref' in subschema:
|
|
817
828
|
ref = subschema['$ref']
|
|
818
829
|
ref_path_str = f"{from_schema.location}{ref}"
|
|
@@ -847,6 +858,8 @@ class ContextBuilder:
|
|
|
847
858
|
for k, v in extra_term_context.items()}
|
|
848
859
|
onto_context[extra_term] = extra_term_context
|
|
849
860
|
|
|
861
|
+
read_properties(subschema, from_schema, onto_context, schema_path)
|
|
862
|
+
|
|
850
863
|
if from_schema:
|
|
851
864
|
current_ref = f"{from_schema.location}{from_schema.ref}"
|
|
852
865
|
if current_ref not in imported_prefixes:
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
$schema: https://json-schema.org/draft/2020-12/schema
|
|
2
|
+
x-jsonld-context: sample-context.jsonld
|
|
3
|
+
$defs:
|
|
4
|
+
objectA:
|
|
5
|
+
type: object
|
|
6
|
+
properties:
|
|
7
|
+
propA:
|
|
8
|
+
type: string
|
|
9
|
+
objectB:
|
|
10
|
+
type: object
|
|
11
|
+
properties:
|
|
12
|
+
propB:
|
|
13
|
+
type: object
|
|
14
|
+
properties:
|
|
15
|
+
objectA:
|
|
16
|
+
$ref: '#/$defs/objectA'
|
|
17
|
+
type: object
|
|
18
|
+
properties:
|
|
19
|
+
objectB:
|
|
20
|
+
$ref: '#/$defs/objectB'
|
|
@@ -4,6 +4,7 @@ from pathlib import Path
|
|
|
4
4
|
|
|
5
5
|
from ogc.na import annotate_schema
|
|
6
6
|
from ogc.na.annotate_schema import SchemaAnnotator, ContextBuilder, ReferencedSchema, SchemaResolver
|
|
7
|
+
from ogc.na.util import load_yaml
|
|
7
8
|
|
|
8
9
|
THIS_DIR = Path(__file__).parent
|
|
9
10
|
DATA_DIR = THIS_DIR / 'data'
|
|
@@ -65,12 +66,12 @@ class AnnotateSchemaTest(unittest.TestCase):
|
|
|
65
66
|
def test_annotate_provided_context(self):
|
|
66
67
|
annotator = SchemaAnnotator()
|
|
67
68
|
schema = annotator.process_schema(DATA_DIR / 'sample-schema.yml', default_context={
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
'@context': {
|
|
70
|
+
'another': 'http://example.net/another/',
|
|
71
|
+
'propA': 'another:a',
|
|
72
|
+
'propC': 'another:c'
|
|
73
|
+
}
|
|
74
|
+
}).schema
|
|
74
75
|
|
|
75
76
|
self.assertEqual(deep_get(schema, 'properties', 'propA', 'x-jsonld-id'), 'http://example.com/props/a')
|
|
76
77
|
self.assertEqual(deep_get(schema, 'properties', 'propC', 'x-jsonld-id'), 'http://example.net/another/c')
|
|
@@ -121,3 +122,21 @@ class AnnotateSchemaTest(unittest.TestCase):
|
|
|
121
122
|
self.assertEqual(SchemaResolver._get_branch(schema, '#/$defs/age'), anchors.get('age'))
|
|
122
123
|
self.assertEqual(SchemaResolver._get_branch(schema, '#/$defs/deep/properties/inner'),
|
|
123
124
|
anchors.get('innerProp'))
|
|
125
|
+
|
|
126
|
+
def test_defs_annotation(self):
|
|
127
|
+
annotator = SchemaAnnotator()
|
|
128
|
+
orig_schema = load_yaml(DATA_DIR / 'annotate-defs-schema.yml')
|
|
129
|
+
schema = annotator.process_schema(DATA_DIR / 'annotate-defs-schema.yml', contents=orig_schema).schema
|
|
130
|
+
vocab = 'http://example.com/props/'
|
|
131
|
+
self.assertEqual(deep_get(schema, '$defs', 'objectA', 'properties', 'propA', 'x-jsonld-id'),
|
|
132
|
+
vocab + 'a')
|
|
133
|
+
self.assertEqual(deep_get(schema, '$defs', 'objectB', 'properties', 'propB', 'x-jsonld-id'),
|
|
134
|
+
vocab + 'b')
|
|
135
|
+
|
|
136
|
+
orig_schema = load_yaml(DATA_DIR / 'annotate-defs-schema.yml')
|
|
137
|
+
only_defs_schema = {k: v for k, v in orig_schema.items() if k in ('$schema', '$defs', 'x-jsonld-context')}
|
|
138
|
+
schema = annotator.process_schema(DATA_DIR / 'annotate-defs-schema.yml', contents=only_defs_schema).schema
|
|
139
|
+
self.assertEqual(deep_get(schema, '$defs', 'objectA', 'properties', 'propA', 'x-jsonld-id'),
|
|
140
|
+
vocab + 'a')
|
|
141
|
+
self.assertEqual(deep_get(schema, '$defs', 'objectB', 'properties', 'propB', 'x-jsonld-id'),
|
|
142
|
+
vocab + 'b')
|
|
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
|
|
File without changes
|