ogc-na 0.4.2__tar.gz → 0.4.3__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 (63) hide show
  1. {ogc_na-0.4.2 → ogc_na-0.4.3}/PKG-INFO +1 -1
  2. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/_version.py +3 -3
  3. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/annotate_schema.py +21 -8
  4. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc_na.egg-info/PKG-INFO +1 -1
  5. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc_na.egg-info/SOURCES.txt +1 -0
  6. ogc_na-0.4.3/test/data/annotate-defs-schema.yml +20 -0
  7. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/test_annotate_schema.py +25 -6
  8. {ogc_na-0.4.2 → ogc_na-0.4.3}/.github/workflows/mkdocs.yml +0 -0
  9. {ogc_na-0.4.2 → ogc_na-0.4.3}/.github/workflows/python-publish.yml +0 -0
  10. {ogc_na-0.4.2 → ogc_na-0.4.3}/.gitignore +0 -0
  11. {ogc_na-0.4.2 → ogc_na-0.4.3}/LICENSE +0 -0
  12. {ogc_na-0.4.2 → ogc_na-0.4.3}/MANIFEST.in +0 -0
  13. {ogc_na-0.4.2 → ogc_na-0.4.3}/README.md +0 -0
  14. {ogc_na-0.4.2 → ogc_na-0.4.3}/docs/examples.md +0 -0
  15. {ogc_na-0.4.2 → ogc_na-0.4.3}/docs/gen_ref_pages.py +0 -0
  16. {ogc_na-0.4.2 → ogc_na-0.4.3}/docs/index.md +0 -0
  17. {ogc_na-0.4.2 → ogc_na-0.4.3}/docs/jsonld-uplift.md +0 -0
  18. {ogc_na-0.4.2 → ogc_na-0.4.3}/docs/tutorials.md +0 -0
  19. {ogc_na-0.4.2 → ogc_na-0.4.3}/mkdocs.yml +0 -0
  20. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/__init__.py +0 -0
  21. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/domain_config.py +0 -0
  22. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/download.py +0 -0
  23. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/exceptions.py +0 -0
  24. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/gsp.py +0 -0
  25. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/ingest_json.py +0 -0
  26. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/input_filters/__init__.py +0 -0
  27. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/input_filters/csv.py +0 -0
  28. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/input_filters/xlsx.py +0 -0
  29. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/input_filters/xml.py +0 -0
  30. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/models.py +0 -0
  31. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/profile.py +0 -0
  32. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/provenance.py +0 -0
  33. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/update_vocabs.py +0 -0
  34. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/util.py +0 -0
  35. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc/na/validation.py +0 -0
  36. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc_na.egg-info/dependency_links.txt +0 -0
  37. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc_na.egg-info/requires.txt +0 -0
  38. {ogc_na-0.4.2 → ogc_na-0.4.3}/ogc_na.egg-info/top_level.txt +0 -0
  39. {ogc_na-0.4.2 → ogc_na-0.4.3}/pyproject.toml +0 -0
  40. {ogc_na-0.4.2 → ogc_na-0.4.3}/rdf/catalog-v001.xml +0 -0
  41. {ogc_na-0.4.2 → ogc_na-0.4.3}/rdf/domaincfg.vocab.ttl +0 -0
  42. {ogc_na-0.4.2 → ogc_na-0.4.3}/requirements.txt +0 -0
  43. {ogc_na-0.4.2 → ogc_na-0.4.3}/setup.cfg +0 -0
  44. {ogc_na-0.4.2 → ogc_na-0.4.3}/setup.py +0 -0
  45. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/__init__.py +0 -0
  46. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/empty.ttl +0 -0
  47. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/headers.csv +0 -0
  48. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/headers.xlsx +0 -0
  49. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/no-headers.csv +0 -0
  50. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/no-headers.xlsx +0 -0
  51. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/profile_tree.ttl +0 -0
  52. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/profile_tree_cyclic.ttl +0 -0
  53. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/sample-context.jsonld +0 -0
  54. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/sample-schema-prop-c.yml +0 -0
  55. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/sample-schema.yml +0 -0
  56. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/schema-anchors.json +0 -0
  57. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/schema-vocab.yml +0 -0
  58. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/two-sheets.xlsx +0 -0
  59. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/data/uplift_context_valid.yml +0 -0
  60. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/test_ingest_json.py +0 -0
  61. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/test_input_filters_csv.py +0 -0
  62. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/test_input_filters_xlsx.py +0 -0
  63. {ogc_na-0.4.2 → ogc_na-0.4.3}/test/test_profile.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ogc_na
3
- Version: 0.4.2
3
+ Version: 0.4.3
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
  License-Expression: Apache-2.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.2'
32
- __version_tuple__ = version_tuple = (0, 4, 2)
31
+ __version__ = version = '0.4.3'
32
+ __version_tuple__ = version_tuple = (0, 4, 3)
33
33
 
34
- __commit_id__ = commit_id = 'gecba92310'
34
+ __commit_id__ = commit_id = 'gc3c617821'
@@ -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) -> Iterable[str]:
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.update(process_subschema(entry, context_stack, from_schema, level + 1))
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
- used_terms.update(process_subschema(target_schema.subschema, context_stack,
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
- used_terms.update(process_subschema(entry, context_stack, from_schema, level + 1))
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
- used_terms.update(process_subschema(branch, context_stack, from_schema, level))
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
- used_terms.update(process_subschema(pp, context_stack, from_schema, level + 1))
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
- used_terms.update(process_subschema(subschema.get(k), context_stack, from_schema, level + 1))
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():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ogc_na
3
- Version: 0.4.2
3
+ Version: 0.4.3
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
  License-Expression: Apache-2.0
@@ -44,6 +44,7 @@ test/test_ingest_json.py
44
44
  test/test_input_filters_csv.py
45
45
  test/test_input_filters_xlsx.py
46
46
  test/test_profile.py
47
+ test/data/annotate-defs-schema.yml
47
48
  test/data/empty.ttl
48
49
  test/data/headers.csv
49
50
  test/data/headers.xlsx
@@ -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
- '@context': {
69
- 'another': 'http://example.net/another/',
70
- 'propA': 'another:a',
71
- 'propC': 'another:c'
72
- }
73
- }).schema
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