ogc-na 0.3.50__py3-none-any.whl → 0.3.52__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.50'
16
- __version_tuple__ = version_tuple = (0, 3, 50)
15
+ __version__ = version = '0.3.52'
16
+ __version_tuple__ = version_tuple = (0, 3, 52)
ogc/na/annotate_schema.py CHANGED
@@ -143,6 +143,7 @@ ANNOTATION_ID = f'{ANNOTATION_PREFIX}id'
143
143
  ANNOTATION_PREFIXES = f'{ANNOTATION_PREFIX}prefixes'
144
144
  ANNOTATION_EXTRA_TERMS = f'{ANNOTATION_PREFIX}extra-terms'
145
145
  ANNOTATION_BASE = f'{ANNOTATION_PREFIX}base'
146
+ ANNOTATION_VOCAB = f'{ANNOTATION_PREFIX}vocab'
146
147
 
147
148
  ANNOTATION_IGNORE_EXPAND = [ANNOTATION_CONTEXT, ANNOTATION_EXTRA_TERMS, ANNOTATION_PREFIXES]
148
149
 
@@ -233,7 +234,7 @@ class SchemaResolver:
233
234
  return location, fragment
234
235
 
235
236
  def resolve_schema(self, ref: str | Path, from_schema: ReferencedSchema | None = None,
236
- force_contents: dict | None = None) -> ReferencedSchema | None:
237
+ force_contents: dict | str | None = None) -> ReferencedSchema | None:
237
238
  chain = from_schema.chain + [from_schema] if from_schema else []
238
239
  try:
239
240
  schema_source, fragment = self.resolve_ref(ref, from_schema)
@@ -253,9 +254,14 @@ class SchemaResolver:
253
254
  ref=ref,
254
255
  is_json=from_schema.is_json)
255
256
 
256
- contents, is_json = self.load_contents(schema_source)
257
257
  if force_contents:
258
- contents = force_contents
258
+ is_json = False
259
+ if isinstance(force_contents, str):
260
+ contents = load_yaml(content=force_contents)
261
+ else:
262
+ contents = force_contents
263
+ else:
264
+ contents, is_json = self.load_contents(schema_source)
259
265
  if fragment:
260
266
  return ReferencedSchema(location=schema_source, fragment=fragment,
261
267
  subschema=SchemaResolver._get_branch(contents, fragment),
@@ -640,6 +646,10 @@ class SchemaAnnotator:
640
646
 
641
647
  process_subschema(schema, [context], resolved_schema)
642
648
 
649
+ for key in ('@base', '@vocab'):
650
+ if context.get(key):
651
+ schema[f"{ANNOTATION_PREFIX}{key[1:]}"] = context[key]
652
+
643
653
  if prefixes:
644
654
  schema[ANNOTATION_PREFIXES] = prefixes
645
655
 
@@ -655,9 +665,10 @@ class ContextBuilder:
655
665
  Builds a JSON-LD context from a set of annotated JSON schemas.
656
666
  """
657
667
 
658
- def __init__(self, location: Path | str = None,
668
+ def __init__(self, location: Path | str,
659
669
  compact: bool = True,
660
670
  schema_resolver: SchemaResolver = None,
671
+ contents: dict | str | None = None,
661
672
  version=1.1):
662
673
  """
663
674
  :param location: file or URL load the annotated schema from
@@ -673,19 +684,20 @@ class ContextBuilder:
673
684
 
674
685
  self.visited_properties: dict[str, str | None] = {}
675
686
  self._missed_properties: dict[str, Any] = {} # Dict instead of set to keep order of insertion
676
- context = self._build_context(self.location, compact)
687
+ context = self._build_context(self.location, compact, contents=contents)
677
688
  if context:
678
689
  context['@version'] = version
679
690
  self.context = {'@context': context}
680
691
 
681
692
  def _build_context(self, schema_location: str | Path,
682
- compact: bool = True) -> dict:
693
+ compact: bool = True,
694
+ contents: dict | str | None = None) -> dict:
683
695
 
684
696
  parsed = self._parsed_schemas.get(schema_location)
685
697
  if parsed:
686
698
  return parsed
687
699
 
688
- root_schema = self.schema_resolver.resolve_schema(schema_location)
700
+ root_schema = self.schema_resolver.resolve_schema(schema_location, force_contents=contents)
689
701
 
690
702
  prefixes = {}
691
703
 
@@ -753,8 +765,10 @@ class ContextBuilder:
753
765
  if not isinstance(subschema, dict):
754
766
  return {}
755
767
 
756
- if subschema.get(ANNOTATION_BASE):
757
- onto_context['@base'] = subschema[ANNOTATION_BASE]
768
+ for key in (ANNOTATION_BASE, ANNOTATION_VOCAB):
769
+ top_level_value = subschema.get(key)
770
+ if top_level_value:
771
+ onto_context[f"@{key[len(ANNOTATION_PREFIX):]}"] = top_level_value
758
772
 
759
773
  read_properties(subschema, from_schema, onto_context, schema_path)
760
774
 
ogc/na/ingest_json.py CHANGED
@@ -686,7 +686,7 @@ def process(input_files: str | Path | Sequence[str | Path],
686
686
  if isinstance(input_files, str) or not isinstance(input_files, Sequence):
687
687
  input_files = (input_files,)
688
688
  if batch:
689
- logger.info("Input files: %s", input_files)
689
+ logger.info("Input files: %s", [str(x) for x in input_files])
690
690
  remaining_fn: deque = deque()
691
691
  for input_file in input_files:
692
692
  if isinstance(input_file, str):
@@ -735,6 +735,8 @@ def process(input_files: str | Path | Sequence[str | Path],
735
735
  logger.warning("Error processing JSON/JSON-LD file, skipping: %s", getattr(e, 'msg', str(e)))
736
736
  else:
737
737
  raise
738
+ except Exception as e:
739
+ raise IOError(f'Error processing input file {fn}') from e
738
740
  else:
739
741
  for input_file in input_files:
740
742
  try:
@@ -867,8 +869,9 @@ def _process_cmdln():
867
869
 
868
870
  parser.add_argument(
869
871
  '--transform-arg',
872
+ metavar='ARG=VALUE',
870
873
  nargs='*',
871
- help='Additional argument to pass to the jq transforms in the form variable=value'
874
+ help='Additional argument to pass to the jq transforms in the form argument=value'
872
875
  )
873
876
 
874
877
  parser.add_argument(
ogc/na/update_vocabs.py CHANGED
@@ -13,6 +13,16 @@ This script can be used as a library, or run directly from the cli;
13
13
  please refer to the
14
14
  [OGC NamingAuthority repository](https://github.com/opengeospatial/NamingAuthority)
15
15
  for usage details on the latter.
16
+
17
+ ## Defining the SPARQL graph URI
18
+
19
+ The graph URI that will be used for an RDF document when pushing the data to a SPARQL endpoint can
20
+ be defined by adding a `http://www.opengis.net/ogc-na#targetGraph` predicate anywhere
21
+ inside it, for example:
22
+
23
+ ```
24
+ [] <http://www.opengis.net/ogc-na#targetGraph> <https://example.com/target-graph> .
25
+ ```
16
26
  """
17
27
 
18
28
  from __future__ import annotations
@@ -26,7 +36,7 @@ from pathlib import Path
26
36
  from typing import Union, Generator
27
37
 
28
38
  import requests
29
- from rdflib import Graph, RDF, SKOS
39
+ from rdflib import Graph, RDF, SKOS, URIRef
30
40
 
31
41
  from ogc.na import util
32
42
  from ogc.na.domain_config import DomainConfiguration, DomainConfigurationEntry
@@ -108,12 +118,21 @@ def get_graph_uri_for_vocab(g: Graph = None) -> Generator[str, None, None]:
108
118
  """
109
119
  Find a target graph URI in a vocabulary [Graph][rdflib.Graph].
110
120
 
111
- In effect, this function merely looks for
121
+ This function looks for any object of the http://www.opengis.net/ogc-na#targetGraph
122
+ predicate, and in its absence for a
112
123
  [SKOS ConceptScheme's](https://www.w3.org/TR/2008/WD-skos-reference-20080829/skos.html#ConceptScheme).
113
124
 
125
+ The following can be included in a Turtle document to specify its graph:
126
+
127
+ ```
128
+ [] <http://www.opengis.net/ogc-na#targetGraph> <https://example.com/target/graph> .
129
+ ```
130
+
114
131
  :param g: the [Graph][rdflib.Graph] for which to find the target URI
115
132
  :return: a [Node][rdflib.term.Node] generator
116
133
  """
134
+ for o in g.objects(predicate=URIRef('http://www.opengis.net/ogc-na#targetGraph')):
135
+ yield str(o)
117
136
  for s in g.subjects(predicate=RDF.type, object=SKOS.ConceptScheme):
118
137
  yield str(s)
119
138
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ogc_na
3
- Version: 0.3.50
3
+ Version: 0.3.52
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,20 +1,20 @@
1
1
  ogc/na/__init__.py,sha256=uzcNiJ3uKFNJ1HBfKxIwgAy2HMUFsLAe5RkrUg8ncac,464
2
- ogc/na/_version.py,sha256=Q_8itBEQeZ4Dn-RIGV0jcZENPIzgmwUxTcLo6vNpPcc,413
3
- ogc/na/annotate_schema.py,sha256=PFBC1wzo-jiWllKhdSSfU6MS6LyaZmt0pxpAu87_FgQ,41254
2
+ ogc/na/_version.py,sha256=nvAcSydy3aySvwpCHeRUJkAZGPXMNWFTF2Wf2WCrWP0,413
3
+ ogc/na/annotate_schema.py,sha256=e6bOIJ05oVqwugWUUuBOQ8P9QL4GKRCE1PKua9kSHRs,41920
4
4
  ogc/na/domain_config.py,sha256=ORzITa1rTrD1MQdpWYrIVW5SwSa9lJd3hnyHIxNgiIU,13947
5
5
  ogc/na/download.py,sha256=2afrLyl4WsAlxkCgXsl47fs9mNKfDmhVpeT2iwNSoq0,3354
6
6
  ogc/na/gsp.py,sha256=KGa2G9i8kPefYTHNPUDoXnNyF7Tiwt8K__Ew_Qa7eeg,6048
7
- ogc/na/ingest_json.py,sha256=V_hZmU8veM6YqARjh8jy50dyhVCcjLLpjdXH6duTL_Y,35503
7
+ ogc/na/ingest_json.py,sha256=OUA9IfSpBbwE6bNE2od64iMzdEg-Q4h5iyowgJsn2M4,35659
8
8
  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
- ogc/na/update_vocabs.py,sha256=joLZxhpBJja5GvaBnt0aHQStKETOCIh5PotUxmJsOHs,18180
11
+ ogc/na/update_vocabs.py,sha256=m9Nd90Aplsm3m7cvNdiemPbnfq6Xq6rUDXGT1GBwDT4,18898
12
12
  ogc/na/util.py,sha256=Ztju3g1YuguUDbk4n2RJfCrl_IIzNAj7linfy24T6VA,12067
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.50.dist-info/METADATA,sha256=48l6MgeDMdvsVxOed4gBRnBLpknpt6FK4kzQWx-KMuo,3829
18
- ogc_na-0.3.50.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
19
- ogc_na-0.3.50.dist-info/top_level.txt,sha256=Kvy3KhzcIhNPT4_nZuJCmS946ptRr_MDyU4IIhZJhCY,4
20
- ogc_na-0.3.50.dist-info/RECORD,,
17
+ ogc_na-0.3.52.dist-info/METADATA,sha256=rMAaHZI6yEznilEzo4gxbU8TyF_GKwzu4wWxCD1MegA,3829
18
+ ogc_na-0.3.52.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
19
+ ogc_na-0.3.52.dist-info/top_level.txt,sha256=Kvy3KhzcIhNPT4_nZuJCmS946ptRr_MDyU4IIhZJhCY,4
20
+ ogc_na-0.3.52.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.1.0)
2
+ Generator: setuptools (74.1.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5