ogc-na 0.2.10__tar.gz → 0.2.11__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 (47) hide show
  1. {ogc_na-0.2.10 → ogc_na-0.2.11}/PKG-INFO +1 -1
  2. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/annotate_schema.py +45 -40
  3. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc_na.egg-info/PKG-INFO +1 -1
  4. {ogc_na-0.2.10 → ogc_na-0.2.11}/.github/workflows/python-publish.yml +0 -0
  5. {ogc_na-0.2.10 → ogc_na-0.2.11}/.gitignore +0 -0
  6. {ogc_na-0.2.10 → ogc_na-0.2.11}/MANIFEST.in +0 -0
  7. {ogc_na-0.2.10 → ogc_na-0.2.11}/README.md +0 -0
  8. {ogc_na-0.2.10 → ogc_na-0.2.11}/docs/examples.md +0 -0
  9. {ogc_na-0.2.10 → ogc_na-0.2.11}/docs/gen_ref_pages.py +0 -0
  10. {ogc_na-0.2.10 → ogc_na-0.2.11}/docs/index.md +0 -0
  11. {ogc_na-0.2.10 → ogc_na-0.2.11}/docs/tutorials.md +0 -0
  12. {ogc_na-0.2.10 → ogc_na-0.2.11}/mkdocs.yml +0 -0
  13. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/__init__.py +0 -0
  14. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/domain_config.py +0 -0
  15. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/download.py +0 -0
  16. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/ingest_json.py +0 -0
  17. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/input_filters/__init__.py +0 -0
  18. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/input_filters/csv.py +0 -0
  19. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/profile.py +0 -0
  20. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/provenance.py +0 -0
  21. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/update_vocabs.py +0 -0
  22. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/util.py +0 -0
  23. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc/na/validation.py +0 -0
  24. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc_na.egg-info/SOURCES.txt +0 -0
  25. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc_na.egg-info/dependency_links.txt +0 -0
  26. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc_na.egg-info/requires.txt +0 -0
  27. {ogc_na-0.2.10 → ogc_na-0.2.11}/ogc_na.egg-info/top_level.txt +0 -0
  28. {ogc_na-0.2.10 → ogc_na-0.2.11}/pyproject.toml +0 -0
  29. {ogc_na-0.2.10 → ogc_na-0.2.11}/rdf/catalog-v001.xml +0 -0
  30. {ogc_na-0.2.10 → ogc_na-0.2.11}/rdf/domaincfg.vocab.ttl +0 -0
  31. {ogc_na-0.2.10 → ogc_na-0.2.11}/requirements.txt +0 -0
  32. {ogc_na-0.2.10 → ogc_na-0.2.11}/setup.cfg +0 -0
  33. {ogc_na-0.2.10 → ogc_na-0.2.11}/setup.py +0 -0
  34. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/__init__.py +0 -0
  35. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/data/empty.ttl +0 -0
  36. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/data/headers.csv +0 -0
  37. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/data/no-headers.csv +0 -0
  38. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/data/profile_tree.ttl +0 -0
  39. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/data/profile_tree_cyclic.ttl +0 -0
  40. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/data/sample-context.jsonld +0 -0
  41. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/data/sample-schema-prop-c.yml +0 -0
  42. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/data/sample-schema.yml +0 -0
  43. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/data/uplift_context_valid.yml +0 -0
  44. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/test_annotate_schema.py +0 -0
  45. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/test_ingest_json.py +0 -0
  46. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/test_input_filters_csv.py +0 -0
  47. {ogc_na-0.2.10 → ogc_na-0.2.11}/test/test_profile.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ogc_na
3
- Version: 0.2.10
3
+ Version: 0.2.11
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/
@@ -402,12 +402,16 @@ class SchemaAnnotator:
402
402
  prop_value[ANNOTATION_ID] = terms[prop]
403
403
  if prop in types:
404
404
  prop_value[ANNOTATION_TYPE] = types[prop]
405
- self._follow_ref(prop_value, fn, url, base_url)
405
+
406
+ process_subschema(prop_value)
406
407
 
407
408
  properties.update({p: {ANNOTATION_ID: terms[p]} for p in empty_properties if p in terms})
408
409
 
409
410
  def process_subschema(subschema):
410
411
 
412
+ if not subschema:
413
+ return
414
+
411
415
  self._follow_ref(subschema, fn, url, base_url)
412
416
 
413
417
  # Annotate oneOf, allOf, anyOf
@@ -426,7 +430,7 @@ class SchemaAnnotator:
426
430
  process_properties(subschema)
427
431
  elif schema_type == 'array':
428
432
  for k in ('prefixItems', 'items', 'contains'):
429
- process_properties(subschema.get(k))
433
+ process_subschema(subschema.get(k))
430
434
 
431
435
  # Annotate $defs
432
436
  for defs_prop in ('$defs', 'definitions'):
@@ -453,7 +457,7 @@ class ContextBuilder:
453
457
  """
454
458
 
455
459
  def __init__(self, fn: Path | str | None = None, url: str | None = None,
456
- compact: bool = True):
460
+ compact: bool = True, ref_mapper: Callable[[str], str] | None = None):
457
461
  """
458
462
  :param fn: file to load the annotated schema from
459
463
  :param url: URL to load the annotated schema from
@@ -461,6 +465,7 @@ class ContextBuilder:
461
465
  self.context = {'@context': {}}
462
466
  self._parsed_schemas: dict[str | Path, dict] = {}
463
467
  self.compact = compact
468
+ self._ref_mapper = ref_mapper
464
469
 
465
470
  context = self._build_context(fn, url)
466
471
  self.context = {'@context': context}
@@ -502,7 +507,7 @@ class ContextBuilder:
502
507
  if prefixes:
503
508
  own_context.update(prefixes)
504
509
 
505
- def read_properties(where: dict):
510
+ def read_properties(where: dict, into_context: dict):
506
511
  if not isinstance(where, dict):
507
512
  return
508
513
  for prop, prop_val in where.get('properties', {}).items():
@@ -513,56 +518,56 @@ class ContextBuilder:
513
518
  if ANNOTATION_TYPE in prop_val:
514
519
  prop_context['@type'] = compact_uri(prop_val[ANNOTATION_TYPE])
515
520
 
516
- if '$ref' in prop_val:
517
- ref_fn, ref_url = resolve_ref(prop_val['$ref'], fn, url, base_url)
518
- prop_context['@context'] = self._build_context(ref_fn, ref_url)
521
+ process_subschema(prop_val, prop_context.setdefault('@context', {}))
522
+
523
+ if not prop_context['@context']:
524
+ prop_context.pop('@context', None)
519
525
 
520
- if len(prop_context) == 1:
526
+ if isinstance(prop_context, dict) and len(prop_context) == 1:
521
527
  # shorten to just the id
522
528
  prop_context = next(iter(prop_context.values()))
523
529
 
524
- own_context[prop] = prop_context
530
+ into_context[prop] = prop_context
531
+
532
+ def process_subschema(ss, into_context: dict):
525
533
 
526
- def process_subschema(ss):
527
534
  if isinstance(ss, dict):
528
535
  if '$ref' in ss:
529
536
  ref_fn, ref_url = resolve_ref(ss['$ref'], fn, url, base_url)
530
537
  merge_dicts(self._build_context(ref_fn, ref_url), own_context)
531
- read_properties(ss)
538
+ read_properties(ss, into_context)
532
539
 
533
- for i in ('allOf', 'anyOf', 'oneOf'):
534
- l = schema.get(i)
535
- if isinstance(l, list):
536
- for sub_schema in l:
537
- process_subschema(sub_schema)
540
+ for i in ('allOf', 'anyOf', 'oneOf'):
541
+ l = ss.get(i)
542
+ if isinstance(l, list):
543
+ for sub_schema in l:
544
+ process_subschema(sub_schema, into_context)
538
545
 
539
- for i in ('$defs', 'definitions'):
540
- d = schema.get(i)
541
- if isinstance(d, dict):
542
- for sub_schema in d.values():
543
- process_subschema(sub_schema)
546
+ for i in ('$defs', 'definitions'):
547
+ d = ss.get(i)
548
+ if isinstance(d, dict):
549
+ for sub_schema in d.values():
550
+ process_subschema(sub_schema, into_context)
544
551
 
545
- read_properties(schema)
552
+ process_subschema(schema, own_context)
546
553
 
547
554
  if self.compact:
548
- context_props = set(own_context.keys())
549
- compact_context = {}
550
- for prop, prop_val in own_context.items():
551
- compact_context[prop] = prop_val
552
- if not isinstance(prop_val, dict):
553
- continue
554
- prop_context = prop_val.pop('@context', None)
555
- if not isinstance(prop_context, dict):
556
- continue
557
- for term, term_val in prop_context.items():
558
- if not term.startswith('@') and term in context_props:
559
- compact_context.setdefault(prop, {}).setdefault('@context', {})[term] = term_val
560
- else:
561
- compact_context[term] = term_val
562
- if len(compact_context[prop]) == 1 and '@id' in compact_context[prop]:
563
- compact_context[prop] = compact_context[prop]['@id']
564
-
565
- own_context = compact_context
555
+
556
+ def compact_branch(branch, existing_terms):
557
+
558
+ for term in list(branch.keys()):
559
+ if term[0] == '@':
560
+ # skip special terms
561
+ continue
562
+ if term in existing_terms and existing_terms[term] == branch[term]:
563
+ # same term exists in ancestor -> delete
564
+ del branch[term]
565
+
566
+ for term, term_value in branch.items():
567
+ if isinstance(term_value, dict) and '@context' in term_value:
568
+ compact_branch(term_value['@context'], {**existing_terms, **branch})
569
+
570
+ compact_branch(own_context, {})
566
571
 
567
572
  self._parsed_schemas[fn or url] = own_context
568
573
  return own_context
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ogc-na
3
- Version: 0.2.10
3
+ Version: 0.2.11
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