udata 10.0.3.dev32628__py2.py3-none-any.whl → 10.0.3.dev32655__py2.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 udata might be problematic. Click here for more details.

@@ -72,6 +72,8 @@ RESOURCE_FILETYPES = OrderedDict(
72
72
  ]
73
73
  )
74
74
 
75
+ OGC_SERVICE_FORMATS = ["ogc:wms", "ogc:wfs", "wms", "wfs"]
76
+
75
77
  CHECKSUM_TYPES = ("sha1", "sha2", "sha256", "md5", "crc")
76
78
  DEFAULT_CHECKSUM_TYPE = "sha1"
77
79
 
udata/core/dataset/rdf.py CHANGED
@@ -49,7 +49,7 @@ from udata.rdf import (
49
49
  from udata.uris import endpoint_for
50
50
  from udata.utils import get_by, safe_unicode
51
51
 
52
- from .constants import UPDATE_FREQUENCIES
52
+ from .constants import OGC_SERVICE_FORMATS, UPDATE_FREQUENCIES
53
53
  from .models import Checksum, Dataset, License, Resource
54
54
 
55
55
  log = logging.getLogger(__name__)
@@ -126,6 +126,44 @@ def owner_to_rdf(dataset, graph=None):
126
126
  return
127
127
 
128
128
 
129
+ def ogc_service_to_rdf(dataset, resource, graph=None, is_hvd=False):
130
+ """
131
+ Build a dataservice on the fly for OGC services distributions
132
+ Inspired from https://github.com/SEMICeu/iso-19139-to-dcat-ap/blob/f61b2921dd398b90b2dd2db14085e75687f7616b/iso-19139-to-dcat-ap.xsl#L1419
133
+ """
134
+ graph = graph or Graph(namespace_manager=namespace_manager)
135
+ service = graph.resource(BNode())
136
+ service.set(RDF.type, DCAT.DataService)
137
+ service.set(DCT.title, Literal(resource.title))
138
+ service.set(DCAT.endpointURL, URIRef(resource.url.split("?")[0]))
139
+ if "request=getcapabilities" in resource.url.lower():
140
+ service.set(DCAT.endpointDescription, URIRef(resource.url))
141
+ service.set(
142
+ DCT.conformsTo,
143
+ URIRef("http://www.opengeospatial.org/standards/" + resource.format.split(":")[-1]),
144
+ )
145
+
146
+ if dataset and dataset.license:
147
+ service.add(DCT.rights, Literal(dataset.license.title))
148
+ if dataset.license.url:
149
+ service.add(DCT.license, URIRef(dataset.license.url))
150
+
151
+ if dataset and dataset.contact_point:
152
+ contact_point = contact_point_to_rdf(dataset.contact_point, graph)
153
+ if contact_point:
154
+ service.set(DCAT.contactPoint, contact_point)
155
+
156
+ if is_hvd:
157
+ # DCAT-AP HVD applicable legislation is also expected at the distribution > accessService level
158
+ service.add(DCATAP.applicableLegislation, URIRef(HVD_LEGISLATION))
159
+ for tag in dataset.tags:
160
+ # Add HVD category if this dataset is tagged HVD
161
+ if tag in TAG_TO_EU_HVD_CATEGORIES:
162
+ service.add(DCATAP.hvdCategory, URIRef(TAG_TO_EU_HVD_CATEGORIES[tag]))
163
+
164
+ return service
165
+
166
+
129
167
  def resource_to_rdf(resource, dataset=None, graph=None, is_hvd=False):
130
168
  """
131
169
  Map a Resource domain model to a DCAT/RDF graph
@@ -175,6 +213,11 @@ def resource_to_rdf(resource, dataset=None, graph=None, is_hvd=False):
175
213
  if is_hvd:
176
214
  # DCAT-AP HVD applicable legislation is also expected at the distribution level
177
215
  r.add(DCATAP.applicableLegislation, URIRef(HVD_LEGISLATION))
216
+
217
+ # Add access service for known OGC service formats
218
+ if resource.format in OGC_SERVICE_FORMATS:
219
+ r.add(DCAT.accessService, ogc_service_to_rdf(dataset, resource, graph, is_hvd))
220
+
178
221
  return r
179
222
 
180
223
 
@@ -197,6 +197,34 @@ class DatasetToRdfTest:
197
197
  assert r.graph.value(checksum.identifier, SPDX.algorithm) == SPDX.checksumAlgorithm_sha1
198
198
  assert checksum.value(SPDX.checksumValue) == Literal(resource.checksum.value)
199
199
 
200
+ def test_ogc_resource_access_service(self):
201
+ license = LicenseFactory()
202
+ resource = ResourceFactory(
203
+ format="ogc:wms",
204
+ url="https://services.data.shom.fr/INSPIRE/wms/r?service=WMS&request=GetCapabilities&version=1.3.0",
205
+ )
206
+ contact = ContactPointFactory()
207
+ dataset = DatasetFactory(resources=[resource], license=license, contact_point=contact)
208
+
209
+ r = resource_to_rdf(resource, dataset)
210
+
211
+ service = r.value(DCAT.accessService)
212
+ assert service.value(RDF.type).identifier == DCAT.DataService
213
+ assert service.value(DCT.title) == Literal(resource.title)
214
+ assert service.value(DCAT.endpointDescription).identifier == URIRef(
215
+ "https://services.data.shom.fr/INSPIRE/wms/r?service=WMS&request=GetCapabilities&version=1.3.0"
216
+ )
217
+ assert service.value(DCAT.endpointURL).identifier == URIRef(
218
+ "https://services.data.shom.fr/INSPIRE/wms/r"
219
+ )
220
+ assert service.value(DCT.conformsTo).identifier == URIRef(
221
+ "http://www.opengeospatial.org/standards/wms"
222
+ )
223
+ assert service.value(DCT.license).identifier == URIRef(license.url)
224
+
225
+ contact_rdf = service.value(DCAT.contactPoint)
226
+ assert contact_rdf.value(RDF.type).identifier == VCARD.Kind
227
+
200
228
  def test_temporal_coverage(self):
201
229
  start = faker.past_date(start_date="-30d")
202
230
  end = faker.future_date(end_date="+30d")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: udata
3
- Version: 10.0.3.dev32628
3
+ Version: 10.0.3.dev32655
4
4
  Summary: Open data portal
5
5
  Home-page: https://github.com/opendatateam/udata
6
6
  Author: Opendata Team
@@ -140,6 +140,7 @@ It is collectively taken care of by members of the
140
140
 
141
141
  ## Current (in progress)
142
142
 
143
+ - Expose OGC services distributions as dataservice [#3203](https://github.com/opendatateam/udata/pull/3203)
143
144
  - Add a matomo "campaign" parameter on links in emails if `MAIL_CAMPAIGN` is configured [#3190](https://github.com/opendatateam/udata/pull/3190)
144
145
  - Add DCAT-AP HVD properties in RDF output if the dataservice or its datasets are tagged hvd [#3187](https://github.com/opendatateam/udata/pull/3187)
145
146
 
@@ -95,7 +95,7 @@ udata/core/dataset/api.py,sha256=cfJU-Py0-4rNU5kpbA90htlCMoiYv_-SPczottDCEfs,297
95
95
  udata/core/dataset/api_fields.py,sha256=ZF24FhKYe5jlV8jXG6YR0Hko9WOuV0446FAlLkEgAWE,17295
96
96
  udata/core/dataset/apiv2.py,sha256=VTE4eYx5udzOdHDUkD7TYpuCtppZMKp1okTSEE1fcgI,16925
97
97
  udata/core/dataset/commands.py,sha256=__hPAk_6iHtgMnEG51ux0vbNWJHxUjXhi1ukH4hF5jY,3714
98
- udata/core/dataset/constants.py,sha256=pkOvrdNBq3k1ojJcv6oSg7kK1IUtb3PqLni-YJ3rKSY,2880
98
+ udata/core/dataset/constants.py,sha256=dlhmg36JnZHw8ib5y875JHjUSa2uaTI-ER0DtQtdLCA,2940
99
99
  udata/core/dataset/csv.py,sha256=y2ySneEwFL24isy7HCvkt3xbdDnKr8qoZrBThpnxBCI,3560
100
100
  udata/core/dataset/events.py,sha256=bSM0nFEX14r4JHc-bAM-7OOuD3JAxUIpw9GgXbOsUyw,4078
101
101
  udata/core/dataset/exceptions.py,sha256=uKiayLSpSzsnLvClObS6hOO0qXEqvURKN7_w8eimQNU,498
@@ -104,7 +104,7 @@ udata/core/dataset/forms.py,sha256=H2oeAD8XckMugnwUcyuKv7o1Xq1rEIlLz9FtxujqbIE,6
104
104
  udata/core/dataset/models.py,sha256=MVNWoRdXYnZjxvuxZgEw8FAvlZhPDfqih53UUoN6uK4,37710
105
105
  udata/core/dataset/permissions.py,sha256=zXQ6kU-Ni3Pl5tDtat-ZPupug9InsNeCN7xRLc2Vcrc,1097
106
106
  udata/core/dataset/preview.py,sha256=IwCqiNTjjXbtA_SSKF52pwnzKKEz0GyYM95QNn2Dkog,2561
107
- udata/core/dataset/rdf.py,sha256=YqsRPrrcwWaV13hflpcEOaN3VXpWW3X8VRtUT2qJH60,26383
107
+ udata/core/dataset/rdf.py,sha256=TGpwjsFF9hpiC3fxcF7Rej97bJjlzRy2vXbisn-a90A,28271
108
108
  udata/core/dataset/search.py,sha256=NXPdBsKeLMeC0tsHSP7xFYilU58xCm4gdU0Yk5XHInM,5607
109
109
  udata/core/dataset/signals.py,sha256=WN4sV-lJlNsRkhcnhoy0SYJvCoYmK_5QFYZd1u-h4gs,161
110
110
  udata/core/dataset/tasks.py,sha256=F31TDKaawtOx6oxmWh9Vu24m0R4KVMouxFyAbaXVG6E,9609
@@ -640,7 +640,7 @@ udata/tests/dataset/test_dataset_actions.py,sha256=bgDjVYjOvu3sX_FCTCzf2snZYSprs
640
640
  udata/tests/dataset/test_dataset_commands.py,sha256=zMPJG2wYwKBee2zI65kmboxf59Zqa84DDjT8V5wj9uo,801
641
641
  udata/tests/dataset/test_dataset_events.py,sha256=hlrpoOiBbnX_COUI9Pzdqlp45GZZDqu5piwupbnPiTI,3601
642
642
  udata/tests/dataset/test_dataset_model.py,sha256=VPF17L5sMpKcFo7JNKmgXnKGAgzy1Ejo470avn3bdcQ,30874
643
- udata/tests/dataset/test_dataset_rdf.py,sha256=BKaspmNYHQ5vrf_UCXteWjis4nq1iz6V5YCVxoUbTQw,35443
643
+ udata/tests/dataset/test_dataset_rdf.py,sha256=TuKomK0SWqO8R1hQkV8iA3w4YvReO0vVHPfBqKP_oaU,36750
644
644
  udata/tests/dataset/test_dataset_tasks.py,sha256=rSafDjCiOyEb2_tVUDN4wqGylF6Yf9VNB769SLmxlwI,2283
645
645
  udata/tests/dataset/test_resource_preview.py,sha256=fp9mSL7unhyM66GR0gwhgX3OGQ4TJt7G9xU-CjsL3HI,3908
646
646
  udata/tests/features/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -706,9 +706,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=nGPoTSbeRlpCQGuxoJ7Oa650flpeeh
706
706
  udata/translations/pt/LC_MESSAGES/udata.po,sha256=f-tilnngNNBEIQdXmm3GbdaLlvbwG9YLLwhqyRD5Lh4,44871
707
707
  udata/translations/sr/LC_MESSAGES/udata.mo,sha256=8RL_aEe-0QJdgY-TNMy7bS4z8X9IOK8-C076dxcp3As,28163
708
708
  udata/translations/sr/LC_MESSAGES/udata.po,sha256=Cp0bKPeIbuAqvFeoey_9ItQbAHIeiFZPnZLa6A6JNbI,51363
709
- udata-10.0.3.dev32628.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
710
- udata-10.0.3.dev32628.dist-info/METADATA,sha256=kz5VPyJ8gQwr8YYN-CCPM1Kc5clSUlQKWeqCfnygwQ8,135300
711
- udata-10.0.3.dev32628.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
712
- udata-10.0.3.dev32628.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
713
- udata-10.0.3.dev32628.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
714
- udata-10.0.3.dev32628.dist-info/RECORD,,
709
+ udata-10.0.3.dev32655.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
710
+ udata-10.0.3.dev32655.dist-info/METADATA,sha256=cBqSe6YkwinrY6RtX31Nri1BwRmEn4lWwegggpqzRA0,135408
711
+ udata-10.0.3.dev32655.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
712
+ udata-10.0.3.dev32655.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
713
+ udata-10.0.3.dev32655.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
714
+ udata-10.0.3.dev32655.dist-info/RECORD,,