ogc-na 0.3.43__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.43'
16
- __version_tuple__ = version_tuple = (0, 3, 43)
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,7 +515,7 @@ 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]
@@ -531,7 +532,7 @@ class SchemaAnnotator:
531
532
  used_terms.add(prop)
532
533
  prop_schema_ctx = {f"{ANNOTATION_PREFIX}{k[1:]}": v
533
534
  for k, v in prop_ctx.items()
534
- if k[0] == '@' and k != '@context'}
535
+ if k in JSON_LD_KEYWORDS and k != '@context'}
535
536
  prop_ctx_base = prop_ctx.get('@context', {}).get('@base')
536
537
  if prop_ctx_base:
537
538
  prop_schema_ctx[ANNOTATION_BASE] = prop_ctx_base
@@ -608,12 +609,14 @@ class SchemaAnnotator:
608
609
  if len(context_stack) == level and context_stack[-1]:
609
610
  extra_terms = {}
610
611
  for k, v in context_stack[-1].items():
611
- 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:
612
613
  if isinstance(v, dict):
613
614
  if len(v) == 1 and '@id' in v:
614
615
  v = v['@id']
615
616
  else:
616
- 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}
617
620
  if isinstance(v, str) and v[-1] in ('#', '/', ':'):
618
621
  prefixes[k] = v
619
622
  else:
@@ -806,7 +809,7 @@ class ContextBuilder:
806
809
  if compact:
807
810
 
808
811
  def compact_uri(uri: str) -> str:
809
- if uri.startswith('@'):
812
+ if uri in JSON_LD_KEYWORDS:
810
813
  # JSON-LD keyword
811
814
  return uri
812
815
 
@@ -821,7 +824,7 @@ class ContextBuilder:
821
824
 
822
825
  def compact_branch(branch, context_stack=None) -> bool:
823
826
  child_context_stack = context_stack + [branch] if context_stack else [branch]
824
- 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)
825
828
 
826
829
  changed = False
827
830
  for term in terms:
@@ -853,7 +856,7 @@ class ContextBuilder:
853
856
 
854
857
  def compact_uris(branch, context_stack=None):
855
858
  child_context_stack = context_stack + [branch] if context_stack else [branch]
856
- 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)
857
860
  for term in terms:
858
861
  term_value = branch.get(term)
859
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.43
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=3SM8TQK0XTeTAO_UFFJd4QeOtXiE6t02ayy_xRZ5U98,413
3
- ogc/na/annotate_schema.py,sha256=zhg8sBSWcfr1JlGALomrKVhrmJQ8HMkIfLVf1yqQg9I,39592
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.43.dist-info/METADATA,sha256=tANOeQvrhO_4uhdtrPJs2zpyG7gjSA-3InVOt-5_mx0,3796
18
- ogc_na-0.3.43.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
19
- ogc_na-0.3.43.dist-info/top_level.txt,sha256=Kvy3KhzcIhNPT4_nZuJCmS946ptRr_MDyU4IIhZJhCY,4
20
- ogc_na-0.3.43.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,,