udata 6.2.1.dev26921__py2.py3-none-any.whl → 6.2.1.dev26928__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.

udata/core/dataset/rdf.py CHANGED
@@ -389,6 +389,7 @@ def remote_url_from_rdf(rdf):
389
389
  except uris.ValidationError:
390
390
  pass
391
391
 
392
+
392
393
  def theme_labels_from_rdf(rdf):
393
394
  for theme in rdf.objects(DCAT.theme):
394
395
  if isinstance(theme, RdfResource):
@@ -399,7 +400,7 @@ def theme_labels_from_rdf(rdf):
399
400
  yield label
400
401
 
401
402
 
402
- def resource_from_rdf(graph_or_distrib, dataset=None):
403
+ def resource_from_rdf(graph_or_distrib, dataset=None, is_additionnal=False):
403
404
  '''
404
405
  Map a Resource domain model to a DCAT/RDF graph
405
406
  '''
@@ -410,9 +411,12 @@ def resource_from_rdf(graph_or_distrib, dataset=None):
410
411
  object=DCAT.Distribution)
411
412
  distrib = graph_or_distrib.resource(node)
412
413
 
413
- download_url = url_from_rdf(distrib, DCAT.downloadURL)
414
- access_url = url_from_rdf(distrib, DCAT.accessURL)
415
- url = safe_unicode(download_url or access_url)
414
+ if not is_additionnal:
415
+ download_url = url_from_rdf(distrib, DCAT.downloadURL)
416
+ access_url = url_from_rdf(distrib, DCAT.accessURL)
417
+ url = safe_unicode(download_url or access_url)
418
+ else:
419
+ url = distrib.identifier.toPython() if isinstance(distrib.identifier, URIRef) else None
416
420
  # we shouldn't create resources without URLs
417
421
  if not url:
418
422
  log.warning(f'Resource without url: {distrib}')
@@ -439,6 +443,8 @@ def resource_from_rdf(graph_or_distrib, dataset=None):
439
443
  resource.checksum = Checksum()
440
444
  resource.checksum.value = rdf_value(checksum, SPDX.checksumValue)
441
445
  resource.checksum.type = algorithm
446
+ if is_additionnal:
447
+ resource.type = 'other'
442
448
 
443
449
  identifier = rdf_value(distrib, DCT.identifier)
444
450
  uri = distrib.identifier.toPython() if isinstance(distrib.identifier, URIRef) else None
@@ -494,6 +500,9 @@ def dataset_from_rdf(graph, dataset=None, node=None):
494
500
  elif isinstance(value, RdfResource):
495
501
  licenses.add(value.identifier.toPython())
496
502
 
503
+ for additionnal in d.objects(DCT.hasPart):
504
+ resource_from_rdf(additionnal, dataset, is_additionnal=True)
505
+
497
506
  default_license = dataset.license or License.default()
498
507
  dataset_license = rdf_value(d, DCT.license)
499
508
  dataset.license = License.guess(dataset_license, *licenses, default=default_license)
@@ -61,6 +61,7 @@
61
61
  <dcat:distribution rdf:resource="http://data.test.org/datasets/1/resources/1"/>
62
62
  <dcterms:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2016-12-14T18:59:02.737480</dcterms:issued>
63
63
  <dcterms:identifier>1</dcterms:identifier>
64
+ <dcterms:hasPart rdf:resource="http://data.test.org/datasets/1/resources/3"/>
64
65
  </dcat:Dataset>
65
66
  </dcat:dataset>
66
67
  <dcat:dataset>
@@ -134,6 +135,10 @@
134
135
  <dcterms:description>A JSON resource</dcterms:description>
135
136
  <dcat:accessURL>http://data.test.org/datasets/3/resources/1/file.json</dcat:accessURL>
136
137
  </dcat:Distribution>
138
+ <foaf:Document rdf:about="http://data.test.org/datasets/1/resources/3">
139
+ <dcterms:title>Resource 1-3</dcterms:title>
140
+ <dcterms:format>JSON</dcterms:format>
141
+ </foaf:Document>
137
142
  <dcterms:Location rdf:about="http://wuEurope.com/"/>
138
143
  <foaf:Organization rdf:about="http://data.test.org/organizations/1">
139
144
  <foaf:name>An Organization</foaf:name>
@@ -297,7 +297,7 @@ class DcatBackendTest:
297
297
  assert dataset.temporal_coverage.start == date(2016, 1, 1)
298
298
  assert dataset.temporal_coverage.end == date(2016, 12, 5)
299
299
 
300
- assert len(dataset.resources) == 2
300
+ assert len(dataset.resources) == 3
301
301
 
302
302
  resource_1 = next(res for res in dataset.resources if res.title == 'Resource 1-1')
303
303
  assert resource_1.filetype == 'remote'
@@ -307,11 +307,20 @@ class DcatBackendTest:
307
307
  assert resource_1.filesize == 12323
308
308
  assert resource_1.description == 'A JSON resource'
309
309
  assert resource_1.url == 'http://data.test.org/datasets/1/resources/1/file.json'
310
+ assert resource_1.type == 'main'
310
311
 
311
312
  resource_2 = next(res for res in dataset.resources if res.title == 'Resource 1-2')
312
313
  assert resource_2.format == 'json'
313
314
  assert resource_2.description == 'A JSON resource'
314
315
  assert resource_2.url == 'http://data.test.org/datasets/1/resources/2/file.json'
316
+ assert resource_2.type == 'main'
317
+
318
+ # Make sure additionnal resource is correctly harvested
319
+ resource_3 = next(res for res in dataset.resources if res.title == 'Resource 1-3')
320
+ assert resource_3.format == 'json'
321
+ assert resource_3.description == ''
322
+ assert resource_3.url == 'http://data.test.org/datasets/1/resources/3'
323
+ assert resource_3.type == 'other'
315
324
 
316
325
  def test_geonetwork_xml_catalog(self, rmock):
317
326
  url = mock_dcat(rmock, 'geonetwork.xml', path='catalog.xml')
@@ -413,7 +422,7 @@ class DcatBackendTest:
413
422
  error = job.errors[0]
414
423
  expected = 'Unable to detect format from extension or mime type'
415
424
  assert error.message == expected
416
-
425
+
417
426
  def test_use_replaced_uris(self, rmock, mocker):
418
427
  mocker.patch.dict(
419
428
  URIS_TO_REPLACE,
@@ -465,7 +474,7 @@ class DcatBackendTest:
465
474
  assert len(job.errors) == 1
466
475
  assert "404 Client Error" in job.errors[0].message
467
476
 
468
-
477
+
469
478
  @pytest.mark.usefixtures('clean_db')
470
479
  @pytest.mark.options(PLUGINS=['csw-dcat'])
471
480
  class CswDcatBackendTest:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: udata
3
- Version: 6.2.1.dev26921
3
+ Version: 6.2.1.dev26928
4
4
  Summary: Open data portal
5
5
  Home-page: https://github.com/opendatateam/udata
6
6
  Author: Opendata Team
@@ -141,6 +141,7 @@ It is collectively taken care of by members of the
141
141
  - Topics: API v2 endpoints [#2913](https://github.com/opendatateam/udata/pull/2913)
142
142
  - Allow for discussions on Topics [#2922](https://github.com/opendatateam/udata/pull/2922)
143
143
  - Raise for status on DCAT harvester calls [#2927](https://github.com/opendatateam/udata/pull/2927)
144
+ - Harvest dcterms:hasPart as 'other' resource in DCAT [#2928](https://github.com/opendatateam/udata/pull/2928)
144
145
  - Make sure harvested resources are marked as remote [#2931](https://github.com/opendatateam/udata/pull/2931)
145
146
  - Use GET and POST harvest BaseBackend utility to have user-agent [#2930](https://github.com/opendatateam/udata/pull/2930)
146
147
  - Use LazyReferenceField on Topic datasets and reuses [#2924](https://github.com/opendatateam/udata/pull/2924)
@@ -84,7 +84,7 @@ udata/core/dataset/forms.py,sha256=HXlH9lKTc2mXQi1L-ulBokJPBCGLKXYxG5iB0-kM9-w,6
84
84
  udata/core/dataset/models.py,sha256=GDagMZM2FKJLDxg6bD8zu_Hiz0GfLeBrNB5alScLG5U,33676
85
85
  udata/core/dataset/permissions.py,sha256=3F2J7le3_rEYNhh88o3hSRWHAAt01_yHJM6RPmvCrRo,1090
86
86
  udata/core/dataset/preview.py,sha256=puPKT3fBD7ezAcT6owh0JK1_rGNDFZOqgT223qGn3LY,2597
87
- udata/core/dataset/rdf.py,sha256=6SDNXv9I45f60ZmfA0Ko5V1gQgdRzm4l3CjySeyb8HM,17592
87
+ udata/core/dataset/rdf.py,sha256=zvCE9L3d8lgObUPOQQl3wDoK8tM7eovt9gqKOJkb_uY,17932
88
88
  udata/core/dataset/search.py,sha256=6Za7DMU18kfTMKELHCTjy13enbVRuFt8zyqyEkBrQg0,5561
89
89
  udata/core/dataset/signals.py,sha256=TK6dfrOUitZZkGGOh6XmhYqYvIjzZpI70JTLV4k-JRM,161
90
90
  udata/core/dataset/tasks.py,sha256=VB1sQ6Fwbax46IRLGyZUDPGgGOWBYrzAlKzV3npDCyM,8412
@@ -256,7 +256,7 @@ udata/harvest/tests/factories.py,sha256=l1FRbM6-iblzIm4HDwQ23EnmoSDguQFGN4l_ygzS
256
256
  udata/harvest/tests/test_actions.py,sha256=7xSpouCAcf5p_bd38zHCyPN7sKWUUZXA7IlpI-yNVrQ,27603
257
257
  udata/harvest/tests/test_api.py,sha256=QXhseHfnkBEmMbIJzroMdDYGLDj6Njal1s-2sn0xhEM,14888
258
258
  udata/harvest/tests/test_base_backend.py,sha256=JA8Df1Eu-lEPLZfxyK81bsmT6exOjV_3PtKHJekAp5g,12092
259
- udata/harvest/tests/test_dcat_backend.py,sha256=cOtRJoMgU4skhS5cNfQw6NaTS5gEx-OvudqUKvE_v98,20520
259
+ udata/harvest/tests/test_dcat_backend.py,sha256=-6x5msEX1Z0eeAWzcNA8oE1OQbh3-mC0oF9F2Vnxvdw,20950
260
260
  udata/harvest/tests/test_filters.py,sha256=V2HFZlexIJa6r1DX6g2ktvIgjg4gSY11QPfPOd3_Oug,2370
261
261
  udata/harvest/tests/test_models.py,sha256=Wh2_Bwvfdrj0Fsh8Q8j4yTfLwmYv5WiGbGhrvf6zbII,905
262
262
  udata/harvest/tests/test_notifications.py,sha256=ZwtwioittW3XcZc0x6zbHjs1dVaAxPytlVymnJa5w0E,817
@@ -266,7 +266,7 @@ udata/harvest/tests/csw_dcat/geonetworkv4-page-3.xml,sha256=fsN0E4TVd_ts-sYA612y
266
266
  udata/harvest/tests/csw_dcat/geonetworkv4-page-5.xml,sha256=0VmPp1kspik7YAmOFyr-3yJLzWGA6kuQp_x_w-W385o,21213
267
267
  udata/harvest/tests/dcat/bnodes.jsonld,sha256=Leqny-ccp30564yojQYYckw_HKbhR0f5qUCaavc2ruE,7964
268
268
  udata/harvest/tests/dcat/bnodes.xml,sha256=xTycYrpe8Kq7CAXchV7IsVNQpkNp1xh3300dcEFt9uo,7850
269
- udata/harvest/tests/dcat/catalog.xml,sha256=DY-lIDWcpZZe55SJqWvfLlsrnFPM6vTA7ArIwaoA7fc,8391
269
+ udata/harvest/tests/dcat/catalog.xml,sha256=InHzKoiz217m98WK5zdNd6KWZT5iHYWGhIx0EU1TOWw,8660
270
270
  udata/harvest/tests/dcat/flat.jsonld,sha256=BAw08MDhtW9Px3q6RAoTIqO_OwJmAwBS9EpC8BY_x98,8459
271
271
  udata/harvest/tests/dcat/geonetwork.xml,sha256=9_pksE74Zzkbgs9okj6hEbo8CJS0FZjEnIdvopKfm7k,7928
272
272
  udata/harvest/tests/dcat/nested.jsonld,sha256=GxGIsMcMv2PfxYj-e_gAnCXodxCgpwJKMA3wIb7xA7g,3911
@@ -630,9 +630,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=N4XoaycpcOJnsi2qJobZa8lEAYVpu7
630
630
  udata/translations/pt/LC_MESSAGES/udata.po,sha256=sv-oskJPJ6SStK6TWA-Wa28ssmrJweWLw4M__Sln-_Q,41902
631
631
  udata/translations/sr/LC_MESSAGES/udata.mo,sha256=TfrjXLjrnuIo5N3Px0mMnrlWa-n4HmJUBP5pbLsGjkA,29086
632
632
  udata/translations/sr/LC_MESSAGES/udata.po,sha256=QsVYsk6FRVtKmfxKv427qPmYcw2mx_wuE79aaWNeaYA,48743
633
- udata-6.2.1.dev26921.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
634
- udata-6.2.1.dev26921.dist-info/METADATA,sha256=Z1xSLblDNH_q0r8hddWXRes3sMGhKBv7sbtx5u8ITJY,113363
635
- udata-6.2.1.dev26921.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
636
- udata-6.2.1.dev26921.dist-info/entry_points.txt,sha256=ZqIUHhOth0MMQvMIeuhODbUCDwjR-Hvo7PaKrMwTKuQ,384
637
- udata-6.2.1.dev26921.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
638
- udata-6.2.1.dev26921.dist-info/RECORD,,
633
+ udata-6.2.1.dev26928.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
634
+ udata-6.2.1.dev26928.dist-info/METADATA,sha256=NkxZ3ziL1apUekBk-6M8L1RYKJ5RUxDMCSKBzbNlOo8,113474
635
+ udata-6.2.1.dev26928.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
636
+ udata-6.2.1.dev26928.dist-info/entry_points.txt,sha256=ZqIUHhOth0MMQvMIeuhODbUCDwjR-Hvo7PaKrMwTKuQ,384
637
+ udata-6.2.1.dev26928.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
638
+ udata-6.2.1.dev26928.dist-info/RECORD,,