[ckan-changes] commit/ckanext-harvest: amercader: [base harvester] Custom tag munge function. TODO: check with flexible tags

Bitbucket commits-noreply at bitbucket.org
Wed Nov 23 11:06:17 UTC 2011


1 new commit in ckanext-harvest:


https://bitbucket.org/okfn/ckanext-harvest/changeset/2dea33b02705/
changeset:   2dea33b02705
branch:      feature-new-ckan-harvester-features
user:        amercader
date:        2011-11-23 12:05:52
summary:     [base harvester] Custom tag munge function. TODO: check with flexible tags
affected #:  1 file

diff -r bf67919f7e11c586d5c427e1ae569a56d4aca7a4 -r 2dea33b02705148bf49acadde439ec2e50d9c4f4 ckanext/harvest/harvesters/base.py
--- a/ckanext/harvest/harvesters/base.py
+++ b/ckanext/harvest/harvesters/base.py
@@ -1,5 +1,5 @@
 import logging
-
+import re
 
 from ckan import model
 from ckan.model import Session, Package
@@ -7,7 +7,7 @@
 
 from ckan.logic.schema import default_package_schema
 from ckan.lib.navl.validators import ignore_missing
-from ckan.lib.munge import munge_title_to_name, munge_tag
+from ckan.lib.munge import munge_title_to_name,substitute_ascii_equivalents
 
 from ckanext.harvest.model import HarvestJob, HarvestObject, HarvestGatherError, \
                                     HarvestObjectError
@@ -17,6 +17,11 @@
 
 log = logging.getLogger(__name__)
 
+def munge_tag(tag):
+    tag = substitute_ascii_equivalents(tag)
+    tag = tag.lower().strip()
+    return re.sub(r'[^a-zA-Z0-9 -]', '', tag).replace(' ', '-')
+
 class HarvesterBase(SingletonPlugin):
     '''
     Generic class for  harvesters with helper functions

Repository URL: https://bitbucket.org/okfn/ckanext-harvest/

--

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