[base harvester] Custom tag munge function. TODO: check with flexible tags
This commit is contained in:
parent
cfaba6e1e8
commit
da469ab08e
|
@ -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 import ValidationError, NotFound, get_action
|
|||
|
||||
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 @@ from ckanext.harvest.interfaces import IHarvester
|
|||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue