Skip to content

Commit

Permalink
feat: Update exporting media type
Browse files Browse the repository at this point in the history
Previously this function assumed that media_type was something like
'HTML', but now it is mapped to the actual media_type, e.g.
'application/html'. See media_type_mapping.yaml in
ckanext-switzerland-ng for a full mapping of media types.
  • Loading branch information
bellisk committed Dec 4, 2023
1 parent f87cc4b commit 236bd96
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ckanext/dcatapchharvest/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,13 +1079,12 @@ def _format_and_media_type_to_graph(self, resource_dict, distribution):

# Export media type if it matches IANA media type vocabulary
if resource_dict.get('media_type'):
lowercase_media_type_value = \
resource_dict.get('media_type').lower()
if lowercase_media_type_value in valid_media_types:
media_type_subtype = resource_dict.get('media_type').split('/')[1]
if media_type_subtype in valid_media_types:
g.add((
distribution,
DCAT.mediaType,
URIRef(valid_media_types[lowercase_media_type_value])
URIRef(valid_media_types[media_type_subtype])
))

def graph_from_catalog(self, catalog_dict, catalog_ref):
Expand Down

0 comments on commit 236bd96

Please sign in to comment.