udata 8.0.2.dev29304__py2.py3-none-any.whl → 9.0.1.dev29390__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/__init__.py +1 -1
- udata/core/dataset/csv.py +8 -1
- udata/core/dataset/rdf.py +18 -4
- udata/core/organization/csv.py +5 -3
- udata/core/reuse/csv.py +3 -0
- udata/core/site/api.py +4 -1
- udata/rdf.py +4 -0
- udata/static/chunks/{11.ae54612e36c6d46f85db.js → 11.7266fef2dddc1db403d9.js} +3 -3
- udata/static/chunks/{11.ae54612e36c6d46f85db.js.map → 11.7266fef2dddc1db403d9.js.map} +1 -1
- udata/static/chunks/{13.d8ccb992a49875966313.js → 13.91b177d7d531fd55cf5d.js} +2 -2
- udata/static/chunks/{13.d8ccb992a49875966313.js.map → 13.91b177d7d531fd55cf5d.js.map} +1 -1
- udata/static/chunks/{16.4565605e68bab129a471.js → 16.e866757bab9f6b0a3f1b.js} +2 -2
- udata/static/chunks/{16.4565605e68bab129a471.js.map → 16.e866757bab9f6b0a3f1b.js.map} +1 -1
- udata/static/chunks/{19.f993a75d5bfe2382548d.js → 19.619b83ac597516dcd03e.js} +3 -3
- udata/static/chunks/{19.f993a75d5bfe2382548d.js.map → 19.619b83ac597516dcd03e.js.map} +1 -1
- udata/static/chunks/{5.cc2e7bf65ef32f9c8604.js → 5.48417db6b33328fa9d6a.js} +3 -3
- udata/static/chunks/{5.cc2e7bf65ef32f9c8604.js.map → 5.48417db6b33328fa9d6a.js.map} +1 -1
- udata/static/chunks/{6.cad898a38692eda28965.js → 6.f84539bd4c419b36cc19.js} +3 -3
- udata/static/chunks/{6.cad898a38692eda28965.js.map → 6.f84539bd4c419b36cc19.js.map} +1 -1
- udata/static/chunks/{9.d5b992e9ef51921aeb57.js → 9.07503e7f7ec02919f696.js} +2 -2
- udata/static/chunks/{9.d5b992e9ef51921aeb57.js.map → 9.07503e7f7ec02919f696.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- udata/tests/dataset/test_dataset_rdf.py +17 -2
- udata/tests/site/test_site_rdf.py +16 -0
- {udata-8.0.2.dev29304.dist-info → udata-9.0.1.dev29390.dist-info}/METADATA +6 -1
- {udata-8.0.2.dev29304.dist-info → udata-9.0.1.dev29390.dist-info}/RECORD +31 -31
- {udata-8.0.2.dev29304.dist-info → udata-9.0.1.dev29390.dist-info}/LICENSE +0 -0
- {udata-8.0.2.dev29304.dist-info → udata-9.0.1.dev29390.dist-info}/WHEEL +0 -0
- {udata-8.0.2.dev29304.dist-info → udata-9.0.1.dev29390.dist-info}/entry_points.txt +0 -0
- {udata-8.0.2.dev29304.dist-info → udata-9.0.1.dev29390.dist-info}/top_level.txt +0 -0
udata/__init__.py
CHANGED
udata/core/dataset/csv.py
CHANGED
|
@@ -19,6 +19,9 @@ class DatasetCsvAdapter(csv.Adapter):
|
|
|
19
19
|
('url', 'external_url'),
|
|
20
20
|
('organization', 'organization.name'),
|
|
21
21
|
('organization_id', 'organization.id'),
|
|
22
|
+
('owner', 'owner.slug'), # in case it's owned by a user, or introduce 'owner_type'?
|
|
23
|
+
('owner_id', 'owner.id'),
|
|
24
|
+
# 'contact_point', # ?
|
|
22
25
|
'description',
|
|
23
26
|
'frequency',
|
|
24
27
|
'license',
|
|
@@ -26,19 +29,20 @@ class DatasetCsvAdapter(csv.Adapter):
|
|
|
26
29
|
'temporal_coverage.end',
|
|
27
30
|
'spatial.granularity',
|
|
28
31
|
('spatial.zones', serialize_spatial_zones),
|
|
29
|
-
'private',
|
|
30
32
|
('featured', lambda o: o.featured or False),
|
|
31
33
|
'created_at',
|
|
32
34
|
'last_modified',
|
|
33
35
|
('tags', lambda o: ','.join(o.tags)),
|
|
34
36
|
('archived', lambda o: o.archived or False),
|
|
35
37
|
('resources_count', lambda o: len(o.resources)),
|
|
38
|
+
('main_resources_count', lambda o: len([r for r in o.resources if r.type == 'main'])),
|
|
36
39
|
'downloads',
|
|
37
40
|
('harvest.backend', lambda r: r.harvest and r.harvest.backend),
|
|
38
41
|
('harvest.domain', lambda r: r.harvest and r.harvest.domain),
|
|
39
42
|
('harvest.created_at', lambda r: r.harvest and r.harvest.created_at),
|
|
40
43
|
('harvest.modified_at', lambda r: r.harvest and r.harvest.modified_at),
|
|
41
44
|
('quality_score', lambda o: format(o.quality['score'], '.2f')),
|
|
45
|
+
# schema? what is the schema of a dataset?
|
|
42
46
|
)
|
|
43
47
|
|
|
44
48
|
def dynamic_fields(self):
|
|
@@ -85,6 +89,9 @@ class ResourcesCsvAdapter(csv.NestedAdapter):
|
|
|
85
89
|
('downloads', lambda o: int(o.metrics.get('views', 0))),
|
|
86
90
|
('harvest.created_at', lambda o: o.harvest and o.harvest.created_at),
|
|
87
91
|
('harvest.modified_at', lambda o: o.harvest and o.harvest.modified_at),
|
|
92
|
+
('schema_name', 'schema.name'),
|
|
93
|
+
('schema_version', 'schema.version'),
|
|
94
|
+
('preview_url', lambda o: o.preview_url or False),
|
|
88
95
|
)
|
|
89
96
|
attribute = 'resources'
|
|
90
97
|
|
udata/core/dataset/rdf.py
CHANGED
|
@@ -22,9 +22,10 @@ from udata.frontend.markdown import parse_html
|
|
|
22
22
|
from udata.core.dataset.models import HarvestDatasetMetadata, HarvestResourceMetadata
|
|
23
23
|
from udata.models import db, ContactPoint
|
|
24
24
|
from udata.rdf import (
|
|
25
|
-
DCAT, DCT, FREQ, SCV, SKOS, SPDX, SCHEMA, EUFREQ, EUFORMAT, IANAFORMAT, VCARD, RDFS,
|
|
26
|
-
namespace_manager, schema_from_rdf, url_from_rdf
|
|
25
|
+
DCAT, DCATAP, DCT, FREQ, SCV, SKOS, SPDX, SCHEMA, EUFREQ, EUFORMAT, IANAFORMAT, VCARD, RDFS,
|
|
26
|
+
HVD_LEGISLATION, namespace_manager, schema_from_rdf, url_from_rdf
|
|
27
27
|
)
|
|
28
|
+
from udata.tags import slug as slugify_tag
|
|
28
29
|
from udata.utils import get_by, safe_unicode
|
|
29
30
|
from udata.uris import endpoint_for
|
|
30
31
|
|
|
@@ -85,6 +86,7 @@ EU_HVD_CATEGORIES = {
|
|
|
85
86
|
"http://data.europa.eu/bna/c_dd313021": "Observation de la terre et environnement",
|
|
86
87
|
"http://data.europa.eu/bna/c_e1da4e07": "Statistiques"
|
|
87
88
|
}
|
|
89
|
+
TAG_TO_EU_HVD_CATEGORIES = {slugify_tag(EU_HVD_CATEGORIES[uri]): uri for uri in EU_HVD_CATEGORIES}
|
|
88
90
|
|
|
89
91
|
|
|
90
92
|
class HTMLDetector(HTMLParser):
|
|
@@ -141,7 +143,7 @@ def owner_to_rdf(dataset, graph=None):
|
|
|
141
143
|
return
|
|
142
144
|
|
|
143
145
|
|
|
144
|
-
def resource_to_rdf(resource, dataset=None, graph=None):
|
|
146
|
+
def resource_to_rdf(resource, dataset=None, graph=None, is_hvd=False):
|
|
145
147
|
'''
|
|
146
148
|
Map a Resource domain model to a DCAT/RDF graph
|
|
147
149
|
'''
|
|
@@ -180,6 +182,9 @@ def resource_to_rdf(resource, dataset=None, graph=None):
|
|
|
180
182
|
checksum.add(SPDX.algorithm, getattr(SPDX, algorithm))
|
|
181
183
|
checksum.add(SPDX.checksumValue, Literal(resource.checksum.value))
|
|
182
184
|
r.add(SPDX.checksum, checksum)
|
|
185
|
+
if is_hvd:
|
|
186
|
+
# DCAT-AP HVD applicable legislation is also expected at the distribution level
|
|
187
|
+
r.add(DCATAP.applicableLegislation, URIRef(HVD_LEGISLATION))
|
|
183
188
|
return r
|
|
184
189
|
|
|
185
190
|
|
|
@@ -214,11 +219,20 @@ def dataset_to_rdf(dataset, graph=None):
|
|
|
214
219
|
if dataset.acronym:
|
|
215
220
|
d.set(SKOS.altLabel, Literal(dataset.acronym))
|
|
216
221
|
|
|
222
|
+
# Add DCAT-AP HVD properties if the dataset is tagged hvd.
|
|
223
|
+
# See https://semiceu.github.io/DCAT-AP/releases/2.2.0-hvd/
|
|
224
|
+
is_hvd = current_app.config['HVD_SUPPORT'] and 'hvd' in dataset.tags
|
|
225
|
+
if is_hvd:
|
|
226
|
+
d.add(DCATAP.applicableLegislation, URIRef(HVD_LEGISLATION))
|
|
227
|
+
|
|
217
228
|
for tag in dataset.tags:
|
|
218
229
|
d.add(DCAT.keyword, Literal(tag))
|
|
230
|
+
# Add HVD category if this dataset is tagged HVD
|
|
231
|
+
if is_hvd and tag in TAG_TO_EU_HVD_CATEGORIES:
|
|
232
|
+
d.add(DCATAP.hvdCategory, URIRef(TAG_TO_EU_HVD_CATEGORIES[tag]))
|
|
219
233
|
|
|
220
234
|
for resource in dataset.resources:
|
|
221
|
-
d.add(DCAT.distribution, resource_to_rdf(resource, dataset, graph))
|
|
235
|
+
d.add(DCAT.distribution, resource_to_rdf(resource, dataset, graph, is_hvd))
|
|
222
236
|
|
|
223
237
|
if dataset.temporal_coverage:
|
|
224
238
|
d.set(DCT.temporal, temporal_to_rdf(dataset.temporal_coverage, graph))
|
udata/core/organization/csv.py
CHANGED
|
@@ -15,18 +15,20 @@ class OrganizationCsvAdapter(csv.Adapter):
|
|
|
15
15
|
('url', 'external_url'),
|
|
16
16
|
'description',
|
|
17
17
|
('logo', lambda o: o.logo(external=True)),
|
|
18
|
-
('badges', lambda o: [badge.kind for badge in o.badges]),
|
|
18
|
+
('badges', lambda o: ','.join([badge.kind for badge in o.badges])),
|
|
19
19
|
'created_at',
|
|
20
20
|
'last_modified',
|
|
21
|
+
'business_number_id',
|
|
22
|
+
('members_count', lambda o: len(o.members)),
|
|
21
23
|
)
|
|
22
24
|
|
|
23
25
|
def dynamic_fields(self):
|
|
24
26
|
return csv.metric_fields(Organization) + self.get_dynamic_field_downloads()
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
def get_dynamic_field_downloads(self):
|
|
27
29
|
downloads_counts = self.get_downloads_counts()
|
|
28
30
|
return [('downloads', lambda o: downloads_counts.get(str(o.id), 0))]
|
|
29
|
-
|
|
31
|
+
|
|
30
32
|
def get_downloads_counts(self):
|
|
31
33
|
'''
|
|
32
34
|
Prefetch all the resources' downloads for all selected organization into memory
|
udata/core/reuse/csv.py
CHANGED
|
@@ -15,10 +15,13 @@ class ReuseCsvAdapter(csv.Adapter):
|
|
|
15
15
|
('remote_url', 'url'),
|
|
16
16
|
('organization', 'organization.name'),
|
|
17
17
|
('organization_id', 'organization.id'),
|
|
18
|
+
('owner', 'owner.slug'), # in case it's owned by a user
|
|
19
|
+
('owner_id', 'owner.id'),
|
|
18
20
|
('image', lambda r: r.image(external=True)),
|
|
19
21
|
('featured', lambda r: r.featured or False),
|
|
20
22
|
'created_at',
|
|
21
23
|
'last_modified',
|
|
24
|
+
'topic',
|
|
22
25
|
('tags', lambda r: ','.join(r.tags)),
|
|
23
26
|
('datasets', lambda r: ','.join([str(d.id) for d in r.datasets])),
|
|
24
27
|
)
|
udata/core/site/api.py
CHANGED
|
@@ -105,7 +105,10 @@ class SiteRdfCatalogFormat(API):
|
|
|
105
105
|
params = multi_to_dict(request.args)
|
|
106
106
|
page = int(params.get('page', 1))
|
|
107
107
|
page_size = int(params.get('page_size', 100))
|
|
108
|
-
datasets = Dataset.objects.visible()
|
|
108
|
+
datasets = Dataset.objects.visible()
|
|
109
|
+
if 'tag' in params:
|
|
110
|
+
datasets = datasets.filter(tags=params.get('tag', ''))
|
|
111
|
+
datasets = datasets.paginate(page, page_size)
|
|
109
112
|
catalog = build_catalog(current_site, datasets, format=format)
|
|
110
113
|
# bypass flask-restplus make_response, since graph_response
|
|
111
114
|
# is handling the content negociation directly
|
udata/rdf.py
CHANGED
|
@@ -21,6 +21,7 @@ log = logging.getLogger(__name__)
|
|
|
21
21
|
# Extra Namespaces
|
|
22
22
|
ADMS = Namespace('http://www.w3.org/ns/adms#')
|
|
23
23
|
DCAT = Namespace('http://www.w3.org/ns/dcat#')
|
|
24
|
+
DCATAP = Namespace('http://data.europa.eu/r5r/')
|
|
24
25
|
HYDRA = Namespace('http://www.w3.org/ns/hydra/core#')
|
|
25
26
|
SCHEMA = Namespace('http://schema.org/')
|
|
26
27
|
SCV = Namespace('http://purl.org/NET/scovo#')
|
|
@@ -35,6 +36,7 @@ VCARD = Namespace('http://www.w3.org/2006/vcard/ns#')
|
|
|
35
36
|
|
|
36
37
|
namespace_manager = NamespaceManager(Graph())
|
|
37
38
|
namespace_manager.bind('dcat', DCAT)
|
|
39
|
+
namespace_manager.bind('dcatap', DCATAP)
|
|
38
40
|
namespace_manager.bind('dct', DCT)
|
|
39
41
|
namespace_manager.bind('foaf', FOAF)
|
|
40
42
|
namespace_manager.bind('foaf', FOAF)
|
|
@@ -98,6 +100,8 @@ RDF_EXTENSIONS = {
|
|
|
98
100
|
# Includes control characters, unicode surrogate characters and unicode end-of-plane non-characters
|
|
99
101
|
ILLEGAL_XML_CHARS = '[\x00-\x08\x0b\x0c\x0e-\x1F\uD800-\uDFFF\uFFFE\uFFFF]'
|
|
100
102
|
|
|
103
|
+
HVD_LEGISLATION = 'http://data.europa.eu/eli/reg_impl/2023/138/oj'
|
|
104
|
+
|
|
101
105
|
|
|
102
106
|
def guess_format(string):
|
|
103
107
|
'''Guess format given an extension or a mime-type'''
|