Wrap tag munging code in config option, defaulting to False.

This commit is contained in:
Rachel Knowler 2014-01-29 10:02:16 +01:00
parent 2b803a3f66
commit 7d71b0a00b
1 changed files with 10 additions and 3 deletions

View File

@ -20,13 +20,20 @@ from ckanext.harvest.model import HarvestJob, HarvestObject, HarvestGatherError,
from ckan.plugins.core import SingletonPlugin, implements from ckan.plugins.core import SingletonPlugin, implements
from ckanext.harvest.interfaces import IHarvester from ckanext.harvest.interfaces import IHarvester
from pylons import config
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def munge_tag(tag): def munge_tag(tag):
clean_tags = config.get('ckanext.harvest.ckanharvester.clean_tags')
if clean_tags:
tag = substitute_ascii_equivalents(tag) tag = substitute_ascii_equivalents(tag)
tag = tag.lower().strip() tag = tag.lower().strip()
return re.sub(r'[^a-zA-Z0-9 -]', '', tag).replace(' ', '-') return re.sub(r'[^a-zA-Z0-9 -]', '', tag).replace(' ', '-')
else:
return tag
class HarvesterBase(SingletonPlugin): class HarvesterBase(SingletonPlugin):