udata 10.0.3__py2.py3-none-any.whl → 10.0.3.dev32594__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.

Files changed (27) hide show
  1. udata/__init__.py +1 -1
  2. udata/commands/fixtures.py +2 -4
  3. udata/core/dataservices/rdf.py +0 -24
  4. udata/core/dataset/constants.py +0 -2
  5. udata/core/dataset/rdf.py +1 -44
  6. udata/harvest/backends/dcat.py +5 -9
  7. udata/static/chunks/{11.bb1c1fb39f740fbbeec0.js → 11.727465d72948bc466d43.js} +3 -3
  8. udata/static/chunks/{11.bb1c1fb39f740fbbeec0.js.map → 11.727465d72948bc466d43.js.map} +1 -1
  9. udata/static/chunks/{19.a2ab343453156343fe37.js → 19.4f7a5b71ef006ac268c1.js} +3 -3
  10. udata/static/chunks/{19.a2ab343453156343fe37.js.map → 19.4f7a5b71ef006ac268c1.js.map} +1 -1
  11. udata/static/chunks/{5.5ceafbe5d5db2c8e7c64.js → 5.448ccace1bf3389d9b38.js} +3 -3
  12. udata/static/chunks/{5.5ceafbe5d5db2c8e7c64.js.map → 5.448ccace1bf3389d9b38.js.map} +1 -1
  13. udata/static/chunks/{6.a6183760bba4a984a92d.js → 6.037369868acc94a7533f.js} +3 -3
  14. udata/static/chunks/{6.a6183760bba4a984a92d.js.map → 6.037369868acc94a7533f.js.map} +1 -1
  15. udata/static/chunks/{8.2109f27ae53f737a3398.js → 8.60610fd40b95ca119141.js} +2 -2
  16. udata/static/chunks/{8.2109f27ae53f737a3398.js.map → 8.60610fd40b95ca119141.js.map} +1 -1
  17. udata/static/common.js +1 -1
  18. udata/static/common.js.map +1 -1
  19. udata/tests/dataset/test_dataset_rdf.py +0 -28
  20. {udata-10.0.3.dist-info → udata-10.0.3.dev32594.dist-info}/METADATA +3 -7
  21. {udata-10.0.3.dist-info → udata-10.0.3.dev32594.dist-info}/RECORD +25 -27
  22. udata/migrations/2024-11-19-keep-only-local_authority-if-also-public_service-organization-badges.py +0 -22
  23. udata/tests/dataservice/test_dataservice_rdf.py +0 -68
  24. {udata-10.0.3.dist-info → udata-10.0.3.dev32594.dist-info}/LICENSE +0 -0
  25. {udata-10.0.3.dist-info → udata-10.0.3.dev32594.dist-info}/WHEEL +0 -0
  26. {udata-10.0.3.dist-info → udata-10.0.3.dev32594.dist-info}/entry_points.txt +0 -0
  27. {udata-10.0.3.dist-info → udata-10.0.3.dev32594.dist-info}/top_level.txt +0 -0
udata/__init__.py CHANGED
@@ -4,5 +4,5 @@
4
4
  udata
5
5
  """
6
6
 
7
- __version__ = "10.0.3"
7
+ __version__ = "10.0.3.dev"
8
8
  __description__ = "Open data portal"
@@ -39,7 +39,7 @@ COMMUNITY_RES_URL = "/api/1/datasets/community_resources"
39
39
  DISCUSSION_URL = "/api/1/discussions"
40
40
 
41
41
 
42
- DEFAULT_FIXTURE_FILE_TAG: str = "v4.0.0"
42
+ DEFAULT_FIXTURE_FILE_TAG: str = "v3.0.0"
43
43
  DEFAULT_FIXTURE_FILE: str = f"https://raw.githubusercontent.com/opendatateam/udata-fixtures/{DEFAULT_FIXTURE_FILE_TAG}/results.json" # noqa
44
44
 
45
45
  DEFAULT_FIXTURES_RESULTS_FILENAME: str = "results.json"
@@ -180,9 +180,7 @@ def get_or_create_user(data):
180
180
  def import_fixtures(source):
181
181
  """Build sample fixture data (users, datasets, reuses, dataservices) from local or remote file."""
182
182
  if source.startswith("http"):
183
- response = requests.get(source)
184
- response.raise_for_status()
185
- json_fixtures = response.json()
183
+ json_fixtures = requests.get(source).json()
186
184
  else:
187
185
  with open(source) as f:
188
186
  json_fixtures = json.load(f)
@@ -7,10 +7,7 @@ from udata.core.dataset.models import Dataset, License
7
7
  from udata.core.dataset.rdf import dataset_to_graph_id, sanitize_html
8
8
  from udata.rdf import (
9
9
  DCAT,
10
- DCATAP,
11
10
  DCT,
12
- HVD_LEGISLATION,
13
- TAG_TO_EU_HVD_CATEGORIES,
14
11
  contact_point_from_rdf,
15
12
  contact_point_to_rdf,
16
13
  namespace_manager,
@@ -141,29 +138,8 @@ def dataservice_to_rdf(dataservice: Dataservice, graph=None):
141
138
  if dataservice.endpoint_description_url:
142
139
  d.set(DCAT.endpointDescription, URIRef(dataservice.endpoint_description_url))
143
140
 
144
- # Add DCAT-AP HVD properties if the dataservice is tagged hvd.
145
- # See https://semiceu.github.io/DCAT-AP/releases/2.2.0-hvd/
146
- is_hvd = current_app.config["HVD_SUPPORT"] and "hvd" in dataservice.tags
147
- if is_hvd:
148
- d.add(DCATAP.applicableLegislation, URIRef(HVD_LEGISLATION))
149
-
150
- hvd_category_tags = set()
151
141
  for tag in dataservice.tags:
152
142
  d.add(DCAT.keyword, Literal(tag))
153
- # Add HVD category if this dataservice is tagged HVD
154
- if is_hvd and tag in TAG_TO_EU_HVD_CATEGORIES:
155
- hvd_category_tags.add(tag)
156
-
157
- if is_hvd:
158
- # We also want to automatically add any HVD category tags of the dataservice's datasets.
159
- for dataset in dataservice.datasets:
160
- if "hvd" not in dataset.tags: # Only check HVD datasets for their categories.
161
- continue
162
- for tag in dataset.tags:
163
- if tag in TAG_TO_EU_HVD_CATEGORIES:
164
- hvd_category_tags.add(tag)
165
- for tag in hvd_category_tags:
166
- d.add(DCATAP.hvdCategory, URIRef(TAG_TO_EU_HVD_CATEGORIES[tag]))
167
143
 
168
144
  # `dataset_to_graph_id(dataset)` URIRef may not exist in the current page
169
145
  # but should exists in the catalog somewhere. Maybe we should create a Node
@@ -72,8 +72,6 @@ RESOURCE_FILETYPES = OrderedDict(
72
72
  ]
73
73
  )
74
74
 
75
- OGC_SERVICE_FORMATS = ["ogc:wms", "ogc:wfs", "wms", "wfs"]
76
-
77
75
  CHECKSUM_TYPES = ("sha1", "sha2", "sha256", "md5", "crc")
78
76
  DEFAULT_CHECKSUM_TYPE = "sha1"
79
77
 
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 OGC_SERVICE_FORMATS, UPDATE_FREQUENCIES
52
+ from .constants import UPDATE_FREQUENCIES
53
53
  from .models import Checksum, Dataset, License, Resource
54
54
 
55
55
  log = logging.getLogger(__name__)
@@ -126,44 +126,6 @@ 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
-
167
129
  def resource_to_rdf(resource, dataset=None, graph=None, is_hvd=False):
168
130
  """
169
131
  Map a Resource domain model to a DCAT/RDF graph
@@ -213,11 +175,6 @@ def resource_to_rdf(resource, dataset=None, graph=None, is_hvd=False):
213
175
  if is_hvd:
214
176
  # DCAT-AP HVD applicable legislation is also expected at the distribution level
215
177
  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
-
221
178
  return r
222
179
 
223
180
 
@@ -54,9 +54,6 @@ URIS_TO_REPLACE = {
54
54
  }
55
55
 
56
56
 
57
- SAFE_PARSER = ET.XMLParser(resolve_entities=False)
58
-
59
-
60
57
  def extract_graph(source, target, node, specs):
61
58
  for p, o in source.predicate_objects(node):
62
59
  target.add((node, p, o))
@@ -253,7 +250,7 @@ class CswDcatBackend(DcatBackend):
253
250
  )
254
251
  response.raise_for_status()
255
252
  content = response.content
256
- tree = ET.fromstring(content, parser=SAFE_PARSER)
253
+ tree = ET.fromstring(content)
257
254
  if tree.tag == "{" + OWS_NAMESPACE + "}ExceptionReport":
258
255
  raise ValueError(f"Failed to query CSW:\n{content}")
259
256
  while tree is not None:
@@ -279,8 +276,7 @@ class CswDcatBackend(DcatBackend):
279
276
  tree = ET.fromstring(
280
277
  self.post(
281
278
  url, data=body.format(start=start, schema=self.DCAT_SCHEMA), headers=headers
282
- ).content,
283
- parser=SAFE_PARSER,
279
+ ).content
284
280
  )
285
281
 
286
282
 
@@ -313,7 +309,7 @@ class CswIso19139DcatBackend(DcatBackend):
313
309
  See https://github.com/SEMICeu/iso-19139-to-dcat-ap for more information on the XSLT.
314
310
  """
315
311
  # Load XSLT
316
- xsl = ET.fromstring(self.get(self.XSL_URL).content, parser=SAFE_PARSER)
312
+ xsl = ET.fromstring(self.get(self.XSL_URL).content)
317
313
  transform = ET.XSLT(xsl)
318
314
 
319
315
  # Start querying and parsing graph
@@ -355,7 +351,7 @@ class CswIso19139DcatBackend(DcatBackend):
355
351
  )
356
352
  response.raise_for_status()
357
353
 
358
- tree_before_transform = ET.fromstring(response.content, parser=SAFE_PARSER)
354
+ tree_before_transform = ET.fromstring(response.content)
359
355
  # Disabling CoupledResourceLookUp to prevent failure on xlink:href
360
356
  # https://github.com/SEMICeu/iso-19139-to-dcat-ap/blob/master/documentation/HowTo.md#parameter-coupledresourcelookup
361
357
  tree = transform(tree_before_transform, CoupledResourceLookUp="'disabled'")
@@ -390,5 +386,5 @@ class CswIso19139DcatBackend(DcatBackend):
390
386
  )
391
387
  response.raise_for_status()
392
388
 
393
- tree_before_transform = ET.fromstring(response.content, parser=SAFE_PARSER)
389
+ tree_before_transform = ET.fromstring(response.content)
394
390
  tree = transform(tree_before_transform, CoupledResourceLookUp="'disabled'")