Drop support for Pylons
This commit is contained in:
parent
74a8b2fdfe
commit
a47a4f1a4f
|
@ -4,8 +4,8 @@ jobs:
|
|||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- name: Install requirements
|
||||
|
@ -19,7 +19,7 @@ jobs:
|
|||
needs: lint
|
||||
strategy:
|
||||
matrix:
|
||||
ckan-version: ["2.10", 2.9, 2.9-py2, 2.8, 2.7]
|
||||
ckan-version: ["2.10", 2.9]
|
||||
fail-fast: false
|
||||
|
||||
name: CKAN ${{ matrix.ckan-version }}
|
||||
|
@ -55,14 +55,8 @@ jobs:
|
|||
# Replace default path to CKAN core config file with the one on the container
|
||||
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini
|
||||
- name: Setup extension (CKAN >= 2.9)
|
||||
if: ${{ matrix.ckan-version != '2.7' && matrix.ckan-version != '2.8' }}
|
||||
run: |
|
||||
ckan -c test.ini db init
|
||||
ckan -c test.ini harvester initdb
|
||||
- name: Setup extension (CKAN < 2.9)
|
||||
if: ${{ matrix.ckan-version == '2.7' || matrix.ckan-version == '2.8' }}
|
||||
run: |
|
||||
paster --plugin=ckan db init -c test.ini
|
||||
paster --plugin=ckanext-harvest harvester initdb -c test.ini
|
||||
- name: Run tests
|
||||
run: pytest --ckan-ini=test.ini --cov=ckanext.harvest --disable-warnings ckanext/harvest/tests
|
||||
|
|
|
@ -16,7 +16,7 @@ from ckan.model import Session, Package, PACKAGE_NAME_MAX_LENGTH
|
|||
|
||||
from ckan.logic.schema import default_create_package_schema
|
||||
from ckan.lib.navl.validators import ignore_missing, ignore
|
||||
from ckan.lib.munge import munge_title_to_name, substitute_ascii_equivalents
|
||||
from ckan.lib.munge import munge_title_to_name, munge_tag
|
||||
|
||||
from ckanext.harvest.model import (HarvestObject, HarvestGatherError,
|
||||
HarvestObjectError, HarvestJob)
|
||||
|
@ -25,25 +25,6 @@ from ckan.plugins.core import SingletonPlugin, implements
|
|||
from ckanext.harvest.interfaces import IHarvester
|
||||
from ckanext.harvest.logic.schema import unicode_safe
|
||||
|
||||
if p.toolkit.check_ckan_version(min_version='2.3'):
|
||||
from ckan.lib.munge import munge_tag
|
||||
else:
|
||||
# Fallback munge_tag for older ckan versions which don't have a decent
|
||||
# munger
|
||||
def _munge_to_length(string, min_length, max_length):
|
||||
'''Pad/truncates a string'''
|
||||
if len(string) < min_length:
|
||||
string += '_' * (min_length - len(string))
|
||||
if len(string) > max_length:
|
||||
string = string[:max_length]
|
||||
return string
|
||||
|
||||
def munge_tag(tag):
|
||||
tag = substitute_ascii_equivalents(tag)
|
||||
tag = tag.lower().strip()
|
||||
tag = re.sub(r'[^a-zA-Z0-9\- ]', '', tag).replace(' ', '-')
|
||||
tag = _munge_to_length(tag, model.MIN_TAG_LENGTH, model.MAX_TAG_LENGTH)
|
||||
return tag
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -13,11 +13,7 @@ from ckan import model
|
|||
import ckan.plugins as p
|
||||
from ckan.lib.plugins import DefaultDatasetForm
|
||||
|
||||
try:
|
||||
from ckan.lib.plugins import DefaultTranslation
|
||||
except ImportError:
|
||||
class DefaultTranslation():
|
||||
pass
|
||||
from ckan.lib.plugins import DefaultTranslation
|
||||
|
||||
import ckanext.harvest
|
||||
from ckanext.harvest.model import setup as model_setup
|
||||
|
@ -28,10 +24,7 @@ from ckanext.harvest.utils import (
|
|||
DATASET_TYPE_NAME
|
||||
)
|
||||
|
||||
if p.toolkit.check_ckan_version(min_version='2.9.0'):
|
||||
from ckanext.harvest.plugin.flask_plugin import MixinPlugin
|
||||
else:
|
||||
from ckanext.harvest.plugin.pylons_plugin import MixinPlugin
|
||||
from ckanext.harvest.plugin.flask_plugin import MixinPlugin
|
||||
|
||||
log = getLogger(__name__)
|
||||
assert not log.disabled
|
||||
|
@ -47,8 +40,7 @@ class Harvest(MixinPlugin, p.SingletonPlugin, DefaultDatasetForm, DefaultTransla
|
|||
p.implements(p.IPackageController, inherit=True)
|
||||
p.implements(p.ITemplateHelpers)
|
||||
p.implements(p.IFacets, inherit=True)
|
||||
if p.toolkit.check_ckan_version(min_version='2.5.0'):
|
||||
p.implements(p.ITranslation, inherit=True)
|
||||
p.implements(p.ITranslation, inherit=True)
|
||||
|
||||
startup = False
|
||||
|
||||
|
@ -274,13 +266,6 @@ class Harvest(MixinPlugin, p.SingletonPlugin, DefaultDatasetForm, DefaultTransla
|
|||
self.startup = False
|
||||
|
||||
def update_config(self, config):
|
||||
if not p.toolkit.check_ckan_version(min_version='2.0'):
|
||||
assert 0, 'CKAN before 2.0 not supported by ckanext-harvest - '\
|
||||
'genshi templates not supported any more'
|
||||
if p.toolkit.asbool(config.get('ckan.legacy_templates', False)):
|
||||
log.warn('Old genshi templates not supported any more by '
|
||||
'ckanext-harvest so you should set ckan.legacy_templates '
|
||||
'option to True any more.')
|
||||
p.toolkit.add_template_directory(config, '../templates')
|
||||
p.toolkit.add_public_directory(config, '../public')
|
||||
p.toolkit.add_resource('../fanstatic_library', 'ckanext-harvest')
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import ckan.plugins as p
|
||||
from ckanext.harvest.utils import DATASET_TYPE_NAME
|
||||
|
||||
|
||||
class MixinPlugin(p.SingletonPlugin):
|
||||
p.implements(p.IRoutes, inherit=True)
|
||||
|
||||
# IRoutes
|
||||
|
||||
def before_map(self, map):
|
||||
|
||||
# Most of the routes are defined via the IDatasetForm interface
|
||||
# (ie they are the ones for a package type)
|
||||
controller = "ckanext.harvest.controllers.view:ViewController"
|
||||
|
||||
map.connect(
|
||||
"{0}_delete".format(DATASET_TYPE_NAME),
|
||||
"/" + DATASET_TYPE_NAME + "/delete/:id",
|
||||
controller=controller,
|
||||
action="delete",
|
||||
)
|
||||
map.connect(
|
||||
"{0}_refresh".format(DATASET_TYPE_NAME),
|
||||
"/" + DATASET_TYPE_NAME + "/refresh/:id",
|
||||
controller=controller,
|
||||
action="refresh",
|
||||
)
|
||||
map.connect(
|
||||
"{0}_admin".format(DATASET_TYPE_NAME),
|
||||
"/" + DATASET_TYPE_NAME + "/admin/:id",
|
||||
controller=controller,
|
||||
action="admin",
|
||||
)
|
||||
map.connect(
|
||||
"{0}_about".format(DATASET_TYPE_NAME),
|
||||
"/" + DATASET_TYPE_NAME + "/about/:id",
|
||||
controller=controller,
|
||||
action="about",
|
||||
)
|
||||
map.connect(
|
||||
"{0}_clear".format(DATASET_TYPE_NAME),
|
||||
"/" + DATASET_TYPE_NAME + "/clear/:id",
|
||||
controller=controller,
|
||||
action="clear",
|
||||
)
|
||||
|
||||
map.connect(
|
||||
"harvest_job_list",
|
||||
"/" + DATASET_TYPE_NAME + "/{source}/job",
|
||||
controller=controller,
|
||||
action="list_jobs",
|
||||
)
|
||||
map.connect(
|
||||
"harvest_job_show_last",
|
||||
"/" + DATASET_TYPE_NAME + "/{source}/job/last",
|
||||
controller=controller,
|
||||
action="show_last_job",
|
||||
)
|
||||
map.connect(
|
||||
"harvest_job_show",
|
||||
"/" + DATASET_TYPE_NAME + "/{source}/job/{id}",
|
||||
controller=controller,
|
||||
action="show_job",
|
||||
)
|
||||
map.connect(
|
||||
"harvest_job_abort",
|
||||
"/" + DATASET_TYPE_NAME + "/{source}/job/{id}/abort",
|
||||
controller=controller,
|
||||
action="abort_job",
|
||||
)
|
||||
|
||||
map.connect(
|
||||
"harvest_object_show",
|
||||
"/" + DATASET_TYPE_NAME + "/object/:id",
|
||||
controller=controller,
|
||||
action="show_object",
|
||||
)
|
||||
map.connect(
|
||||
"harvest_object_for_dataset_show",
|
||||
"/dataset/harvest_object/:id",
|
||||
controller=controller,
|
||||
action="show_object",
|
||||
ref_type="dataset",
|
||||
)
|
||||
|
||||
return map
|
Loading…
Reference in New Issue