Skip to content

Commit

Permalink
Revert hvd labels from rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaudDauce committed May 16, 2024
1 parent 53b2cd8 commit 5fa9e5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
23 changes: 1 addition & 22 deletions udata/core/dataset/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from udata.models import db, ContactPoint
from udata.rdf import (
DCAT, DCT, FREQ, SCV, SKOS, SPDX, SCHEMA, EUFREQ, EUFORMAT, IANAFORMAT, VCARD, RDFS, contact_point_from_rdf,
namespace_manager, rdf_value, sanitize_html, schema_from_rdf, theme_labels_from_rdf, themes_from_rdf, url_from_rdf
namespace_manager, rdf_value, sanitize_html, schema_from_rdf, themes_from_rdf, url_from_rdf
)
from udata.utils import get_by, safe_unicode
from udata.uris import endpoint_for
Expand Down Expand Up @@ -415,27 +415,6 @@ def remote_url_from_rdf(rdf):
except uris.ValidationError:
pass


def theme_labels_from_rdf(rdf):
'''
Get theme labels to use as keywords.
Map HVD keywords from known URIs resources if HVD support is activated.
'''
for theme in rdf.objects(DCAT.theme):
if isinstance(theme, RdfResource):
uri = theme.identifier.toPython()
if current_app.config['HVD_SUPPORT'] and uri in EU_HVD_CATEGORIES:
label = EU_HVD_CATEGORIES[uri]
# Additionnally yield hvd keyword
yield 'hvd'
else:
label = rdf_value(theme, SKOS.prefLabel)
else:
label = theme.toPython()
if label:
yield label


def resource_from_rdf(graph_or_distrib, dataset=None, is_additionnal=False):
'''
Map a Resource domain model to a DCAT/RDF graph
Expand Down
12 changes: 11 additions & 1 deletion udata/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,19 @@ def url_from_rdf(rdf, prop):
return value.identifier.toPython()

def theme_labels_from_rdf(rdf):
'''
Get theme labels to use as keywords.
Map HVD keywords from known URIs resources if HVD support is activated.
'''
for theme in rdf.objects(DCAT.theme):
if isinstance(theme, RdfResource):
label = rdf_value(theme, SKOS.prefLabel)
uri = theme.identifier.toPython()
if current_app.config['HVD_SUPPORT'] and uri in EU_HVD_CATEGORIES:
label = EU_HVD_CATEGORIES[uri]
# Additionnally yield hvd keyword
yield 'hvd'
else:
label = rdf_value(theme, SKOS.prefLabel)
else:
label = theme.toPython()
if label:
Expand Down

0 comments on commit 5fa9e5b

Please sign in to comment.