Merge branch 'ogdch-79-optional-tag-munging'

This commit is contained in:
amercader 2014-02-10 13:13:48 +00:00
commit 3693028009
2 changed files with 12 additions and 4 deletions

View File

@ -206,6 +206,12 @@ field. The currently supported configuration options are:
present in the local CKAN. Setting it to 'create' will make an attempt to present in the local CKAN. Setting it to 'create' will make an attempt to
create the organizations by copying the details from the remote CKAN. create the organizations by copying the details from the remote CKAN.
* clean_tags: By default, tags are not stripped of accent characters, spaces and
capital letters for display. If this option is set to True, accent characters
will be replaced by their ascii equivalents, capital letters replaced by
lower-case ones, and spaces replaced with dashes. Setting this option to False
gives the same effect as leaving it unset.
Here is an example of a configuration object (the one that must be entered in Here is an example of a configuration object (the one that must be entered in
the configuration field):: the configuration field)::

View File

@ -20,6 +20,7 @@ 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
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -150,10 +151,11 @@ class HarvesterBase(SingletonPlugin):
'ignore_auth': True, 'ignore_auth': True,
} }
tags = package_dict.get('tags', []) if self.config and self.config.get('clean_tags', False):
tags = [munge_tag(t) for t in tags] tags = package_dict.get('tags', [])
tags = list(set(tags)) tags = [munge_tag(t) for t in tags]
package_dict['tags'] = tags tags = list(set(tags))
package_dict['tags'] = tags
# Check if package exists # Check if package exists
data_dict = {} data_dict = {}