IClick support
This commit is contained in:
parent
93951db642
commit
27057e0a39
|
@ -1,47 +1,45 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
import click
|
import click
|
||||||
import logging
|
import logging
|
||||||
from ckan.cli import click_config_option
|
|
||||||
from ckan.cli.cli import CkanCommand
|
|
||||||
|
|
||||||
import ckanext.spatial.util as util
|
import ckanext.spatial.util as util
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def get_commands():
|
||||||
@click.group(short_help=u"Validation commands")
|
return [
|
||||||
@click.help_option(u"-h", u"--help")
|
spatial,
|
||||||
@click_config_option
|
spatial_validation
|
||||||
@click.pass_context
|
]
|
||||||
def validation(ctx, config, *args, **kwargs):
|
|
||||||
ctx.obj = CkanCommand(config)
|
|
||||||
|
|
||||||
|
|
||||||
@validation.command()
|
@click.group(u"spatial-validation", short_help=u"Validation commands")
|
||||||
|
def spatial_validation():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@spatial_validation.command()
|
||||||
@click.argument('pkg', required=False)
|
@click.argument('pkg', required=False)
|
||||||
def report(pkg):
|
def report(pkg):
|
||||||
return util.report(pkg)
|
return util.report(pkg)
|
||||||
|
|
||||||
|
|
||||||
@validation.command('report-csv')
|
@spatial_validation.command('report-csv')
|
||||||
@click.argument('filepath')
|
@click.argument('filepath')
|
||||||
def report_csv(filepath):
|
def report_csv(filepath):
|
||||||
return util.report_csv(filepath)
|
return util.report_csv(filepath)
|
||||||
|
|
||||||
|
|
||||||
@validation.command('file')
|
@spatial_validation.command('file')
|
||||||
@click.argument('filepath')
|
@click.argument('filepath')
|
||||||
def validate_file(filepath):
|
def validate_file(filepath):
|
||||||
return util.validate_file(filepath)
|
return util.validate_file(filepath)
|
||||||
|
|
||||||
|
|
||||||
@click.group(short_help=u"Performs spatially related operations.")
|
@click.group(short_help=u"Performs spatially related operations.")
|
||||||
@click.help_option(u"-h", u"--help")
|
def spatial():
|
||||||
@click_config_option
|
pass
|
||||||
@click.pass_context
|
|
||||||
def spatial(ctx, config, *args, **kwargs):
|
|
||||||
ctx.obj = CkanCommand(config)
|
|
||||||
|
|
||||||
|
|
||||||
@spatial.command()
|
@spatial.command()
|
||||||
|
|
|
@ -1,14 +1,25 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import ckan.plugins as p
|
import ckan.plugins as p
|
||||||
import ckanext.spatial.views as blueprints
|
import ckanext.spatial.views as blueprints
|
||||||
|
from ckanext.spatial.cli import get_commands
|
||||||
|
|
||||||
|
|
||||||
class SpatialQueryMixin(p.SingletonPlugin):
|
class SpatialQueryMixin(p.SingletonPlugin):
|
||||||
p.implements(p.IBlueprint)
|
p.implements(p.IBlueprint)
|
||||||
|
p.implements(p.IClick)
|
||||||
|
|
||||||
# IBlueprint
|
# IBlueprint
|
||||||
|
|
||||||
def get_blueprint(self):
|
def get_blueprint(self):
|
||||||
return [blueprints.api]
|
return [blueprints.api]
|
||||||
|
|
||||||
|
# IClick
|
||||||
|
|
||||||
|
def get_commands(self):
|
||||||
|
return get_commands()
|
||||||
|
|
||||||
|
|
||||||
class HarvestMetadataApiMixin(p.SingletonPlugin):
|
class HarvestMetadataApiMixin(p.SingletonPlugin):
|
||||||
p.implements(p.IBlueprint)
|
p.implements(p.IBlueprint)
|
||||||
|
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -45,9 +45,5 @@ setup(
|
||||||
|
|
||||||
[ckan.test_plugins]
|
[ckan.test_plugins]
|
||||||
test_spatial_plugin = ckanext.spatial.tests.test_plugin.plugin:TestSpatialPlugin
|
test_spatial_plugin = ckanext.spatial.tests.test_plugin.plugin:TestSpatialPlugin
|
||||||
|
|
||||||
[console_scripts]
|
|
||||||
spatial = ckanext.spatial.cli:spatial
|
|
||||||
validation = ckanext.spatial.cli:validation
|
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue