[ckan-changes] commit/ckanext-inspire: amercader: Create a licence_url extra with the first URL found in the licence extra
Bitbucket
commits-noreply at bitbucket.org
Wed May 11 15:22:36 UTC 2011
1 new changeset in ckanext-inspire:
http://bitbucket.org/okfn/ckanext-inspire/changeset/106372eb0003/
changeset: r28:106372eb0003
user: amercader
date: 2011-05-11 17:22:24
summary: Create a licence_url extra with the first URL found in the licence extra
affected #: 1 file (462 bytes)
--- a/ckanext/inspire/harvesters.py Wed May 11 14:45:43 2011 +0100
+++ b/ckanext/inspire/harvesters.py Wed May 11 16:22:24 2011 +0100
@@ -10,6 +10,7 @@
'''
from lxml import etree
import urllib2
+from urlparse import urlparse
from datetime import datetime
import logging
@@ -249,6 +250,11 @@
extras[name] = gemini_values[name]
extras['licence'] = gemini_values.get('use-constraints', '')
+ if len(extras['licence']):
+ license_url_extracted = self._extract_first_license_url(extras['licence'])
+ if license_url_extracted:
+ extras['licence_url'] = license_url_extracted
+
extras['access_constraints'] = gemini_values.get('limitations-on-public-access','')
if gemini_values.has_key('temporal-extent-begin'):
#gemini_values['temporal-extent-begin'].sort()
@@ -338,6 +344,13 @@
counter = counter + 1
return None
+ def _extract_first_license_url(self,licences):
+ for licence in licences:
+ o = urlparse(licence)
+ if o.scheme and o.netloc:
+ return licence
+ return None
+
def _create_package_from_data(self, package_data, package = None):
'''
{'extras': {'INSPIRE': 'True',
Repository URL: https://bitbucket.org/okfn/ckanext-inspire/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list