Skip to content

Commit

Permalink
Parse dcat license field
Browse files Browse the repository at this point in the history
  • Loading branch information
jguo144 committed Apr 1, 2024
1 parent ba43d5c commit ef23155
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ckanext/dcat/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import six
from ckan.common import config
from ckan.plugins import toolkit


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -51,6 +52,15 @@ def dcat_to_ckan(dcat_dict):
# 'value': ','.join(dcat_dict.get('language', []))
#})

if dcat_dict.get('license'):
for license in toolkit.get_action('license_list')({}, {}):
if license.get('url') == dcat_dict.get('license'):
package_dict['license_id'] = license.get('id')
break
elif license.get('title') == dcat_dict.get('license'):
package_dict['license_id'] = license.get('id')
break

package_dict['resources'] = []
for distribution in dcat_dict.get('distribution', []):
# Guess format if not present
Expand Down

0 comments on commit ef23155

Please sign in to comment.