ogc-na 0.3.42__py3-none-any.whl → 0.3.44__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 CHANGED
@@ -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.42'
16
- __version_tuple__ = version_tuple = (0, 3, 42)
15
+ __version__ = version = '0.3.44'
16
+ __version_tuple__ = version_tuple = (0, 3, 44)
ogc/na/annotate_schema.py CHANGED
@@ -131,7 +131,8 @@ from urllib.parse import urlparse, urljoin
131
131
  import jsonschema
132
132
  import requests_cache
133
133
 
134
- from ogc.na.util import is_url, load_yaml, LRUCache, dump_yaml, merge_contexts, merge_dicts, dict_contains
134
+ from ogc.na.util import is_url, load_yaml, LRUCache, dump_yaml, \
135
+ merge_contexts, merge_dicts, dict_contains, JSON_LD_KEYWORDS
135
136
 
136
137
  logger = logging.getLogger(__name__)
137
138
 
@@ -340,7 +341,7 @@ def resolve_context(ctx: Path | str | dict | list, expand_uris=True) -> Resolved
340
341
  prefixes = {}
341
342
 
342
343
  def expand_uri(curie, ctx_stack):
343
- if not expand_uris or not ctx_stack or not curie or curie[0] == '@':
344
+ if not expand_uris or not ctx_stack or not curie or curie in JSON_LD_KEYWORDS:
344
345
  return curie
345
346
  if ':' in curie:
346
347
  prefix, localpart = curie.split(':', 1)
@@ -486,18 +487,18 @@ class SchemaAnnotator:
486
487
  if prop in ctx:
487
488
  prop_ctx = ctx[prop]
488
489
  if isinstance(prop_ctx, str):
489
- if vocab and ':' not in prop_ctx and prop_ctx[0] != '@':
490
+ if vocab and ':' not in prop_ctx and prop_ctx not in JSON_LD_KEYWORDS:
490
491
  prop_ctx = f"{vocab}{prop_ctx}"
491
492
  return {'@id': prop_ctx}
492
493
  elif '@id' not in prop_ctx and not vocab:
493
494
  raise ValueError(f'Missing @id for property {prop} in context {json.dumps(ctx, indent=2)}')
494
495
  else:
495
- result = {k: v for k, v in prop_ctx.items() if k.startswith('@')}
496
+ result = {k: v for k, v in prop_ctx.items() if k in JSON_LD_KEYWORDS}
496
497
  if vocab:
497
498
  prop_id = result.get('@id')
498
499
  if not prop_id:
499
500
  result['@id'] = f"{vocab}{prop}"
500
- elif ':' not in prop_id and prop_id[0] != '@':
501
+ elif ':' not in prop_id and prop_id not in JSON_LD_KEYWORDS:
501
502
  result['@id'] = f"{vocab}{prop_id}"
502
503
  return result
503
504
  elif '@vocab' in ctx:
@@ -514,11 +515,14 @@ class SchemaAnnotator:
514
515
 
515
516
  used_terms = set()
516
517
  for prop in list(properties.keys()):
517
- if prop[0] == '@':
518
+ if prop in JSON_LD_KEYWORDS:
518
519
  # skip JSON-LD keywords
519
520
  continue
520
521
  prop_value = properties[prop]
521
522
 
523
+ if not isinstance(prop_value, dict):
524
+ continue
525
+
522
526
  for key in list(prop_value.keys()):
523
527
  if self.ignore_existing and key.startswith(ANNOTATION_PREFIX):
524
528
  prop_value.pop(key, None)
@@ -528,7 +532,7 @@ class SchemaAnnotator:
528
532
  used_terms.add(prop)
529
533
  prop_schema_ctx = {f"{ANNOTATION_PREFIX}{k[1:]}": v
530
534
  for k, v in prop_ctx.items()
531
- if k[0] == '@' and k != '@context'}
535
+ if k in JSON_LD_KEYWORDS and k != '@context'}
532
536
  prop_ctx_base = prop_ctx.get('@context', {}).get('@base')
533
537
  if prop_ctx_base:
534
538
  prop_schema_ctx[ANNOTATION_BASE] = prop_ctx_base
@@ -605,12 +609,14 @@ class SchemaAnnotator:
605
609
  if len(context_stack) == level and context_stack[-1]:
606
610
  extra_terms = {}
607
611
  for k, v in context_stack[-1].items():
608
- if k[0] != '@' and k not in prefixes and k not in used_terms:
612
+ if k not in JSON_LD_KEYWORDS and k not in prefixes and k not in used_terms:
609
613
  if isinstance(v, dict):
610
614
  if len(v) == 1 and '@id' in v:
611
615
  v = v['@id']
612
616
  else:
613
- v = {f"{ANNOTATION_PREFIX}{vk[1:]}": vv for vk, vv in v.items() if vk[0] == '@'}
617
+ v = {f"{ANNOTATION_PREFIX}{vk[1:]}": vv
618
+ for vk, vv in v.items()
619
+ if vk in JSON_LD_KEYWORDS}
614
620
  if isinstance(v, str) and v[-1] in ('#', '/', ':'):
615
621
  prefixes[k] = v
616
622
  else:
@@ -803,7 +809,7 @@ class ContextBuilder:
803
809
  if compact:
804
810
 
805
811
  def compact_uri(uri: str) -> str:
806
- if uri.startswith('@'):
812
+ if uri in JSON_LD_KEYWORDS:
807
813
  # JSON-LD keyword
808
814
  return uri
809
815
 
@@ -818,7 +824,7 @@ class ContextBuilder:
818
824
 
819
825
  def compact_branch(branch, context_stack=None) -> bool:
820
826
  child_context_stack = context_stack + [branch] if context_stack else [branch]
821
- terms = list(k for k in branch.keys() if k[0] != '@')
827
+ terms = list(k for k in branch.keys() if k not in JSON_LD_KEYWORDS)
822
828
 
823
829
  changed = False
824
830
  for term in terms:
@@ -850,7 +856,7 @@ class ContextBuilder:
850
856
 
851
857
  def compact_uris(branch, context_stack=None):
852
858
  child_context_stack = context_stack + [branch] if context_stack else [branch]
853
- terms = list(k for k in branch.keys() if k[0] != '@')
859
+ terms = list(k for k in branch.keys() if k not in JSON_LD_KEYWORDS)
854
860
  for term in terms:
855
861
  term_value = branch.get(term)
856
862
  if isinstance(term_value, str):
ogc/na/util.py CHANGED
@@ -28,6 +28,32 @@ try:
28
28
  except ImportError:
29
29
  from yaml import Loader as YamlLoader, SafeLoader as SafeYamlLoader, Dumper as YamlDumper
30
30
 
31
+ JSON_LD_KEYWORDS = {
32
+ '@base',
33
+ '@container',
34
+ '@context',
35
+ '@direction',
36
+ '@graph',
37
+ '@id',
38
+ '@import',
39
+ '@included',
40
+ '@index',
41
+ '@json',
42
+ '@language',
43
+ '@list',
44
+ '@nest',
45
+ '@none',
46
+ '@prefix',
47
+ '@propagate',
48
+ '@protected',
49
+ '@reverse',
50
+ '@set',
51
+ '@type',
52
+ '@value',
53
+ '@version',
54
+ '@vocab'
55
+ }
56
+
31
57
 
32
58
  class ContextMergeError(Exception):
33
59
  pass
@@ -294,7 +320,7 @@ def merge_contexts(a: dict, b: dict, fix_nest=True) -> dict[str, Any]:
294
320
  for term in list(a.keys()):
295
321
  va = a[term]
296
322
  vb = b.get(term)
297
- if term[0] != '@':
323
+ if term not in JSON_LD_KEYWORDS:
298
324
  if isinstance(va, str):
299
325
  va = {'@id': va}
300
326
  a[term] = va
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ogc_na
3
- Version: 0.3.42
3
+ Version: 0.3.44
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=CtA5dxXeP6X4MyBu3wJZ5PC4Zc3Zg2p2NioUNrcPU7Y,413
3
- ogc/na/annotate_schema.py,sha256=6eymI-aonRipAhNx96IwUsCO8IKT2beOaMPuQv5zpL8,39509
2
+ ogc/na/_version.py,sha256=X8gyyh7AkxhUcMUHqBeELBXHJ4sJvOKOOobJXSUQR78,413
3
+ ogc/na/annotate_schema.py,sha256=lM_YZ5f9d55pskEKRQGSXSLWfhMTBIZIWl5fv2HgVxU,39808
4
4
  ogc/na/domain_config.py,sha256=C6ao37dbXEKv_K7WcfzQgI3H1Hr3c4-3p24hgl2oH54,13896
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=ayMUT9HzNKynpSDTZ8epM8qSMTu4-_KlEL-Zlci2Pnk,11573
12
+ ogc/na/util.py,sha256=r-cwqxqVVH1oXWsWuobTvXFGUVCqwlalN97b85nUN4U,11951
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.42.dist-info/METADATA,sha256=CEx_hGbCZSNAXvFfvEr_vQP7K5R6pQ7G5e_5Ti6b8HM,3796
18
- ogc_na-0.3.42.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
- ogc_na-0.3.42.dist-info/top_level.txt,sha256=Kvy3KhzcIhNPT4_nZuJCmS946ptRr_MDyU4IIhZJhCY,4
20
- ogc_na-0.3.42.dist-info/RECORD,,
17
+ ogc_na-0.3.44.dist-info/METADATA,sha256=JcbuO0vtp33AwDss-kPzDdBxLyDm_IdVGkhMiHEkoc8,3796
18
+ ogc_na-0.3.44.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
+ ogc_na-0.3.44.dist-info/top_level.txt,sha256=Kvy3KhzcIhNPT4_nZuJCmS946ptRr_MDyU4IIhZJhCY,4
20
+ ogc_na-0.3.44.dist-info/RECORD,,