IClick support
This commit is contained in:
parent
f67777c547
commit
1b6e26f5ce
|
@ -10,8 +10,6 @@ import ckan.model as model
|
||||||
|
|
||||||
from . import dbutil
|
from . import dbutil
|
||||||
|
|
||||||
from ckan.cli import error_shout, click_config_option
|
|
||||||
from ckan.cli.cli import CkanCommand
|
|
||||||
import ckan.plugins.toolkit as tk
|
import ckan.plugins.toolkit as tk
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -22,14 +20,16 @@ RESOURCE_URL_REGEX = re.compile("/dataset/[a-z0-9-_]+/resource/([a-z0-9-_]+)")
|
||||||
DATASET_EDIT_REGEX = re.compile("/dataset/edit/([a-z0-9-_]+)")
|
DATASET_EDIT_REGEX = re.compile("/dataset/edit/([a-z0-9-_]+)")
|
||||||
|
|
||||||
|
|
||||||
@click.group(short_help=u"GoogleAnalytics commands")
|
def get_commands():
|
||||||
@click.help_option(u"-h", u"--help")
|
return [
|
||||||
@click_config_option
|
googleanalytics
|
||||||
@click.pass_context
|
]
|
||||||
def googleanalytics(ctx, config, *args, **kwargs):
|
|
||||||
ctx.obj = CkanCommand(config)
|
|
||||||
|
|
||||||
|
|
||||||
|
@click.group(short_help=u"GoogleAnalytics commands")
|
||||||
|
def googleanalytics():
|
||||||
|
pass
|
||||||
|
|
||||||
@googleanalytics.command()
|
@googleanalytics.command()
|
||||||
def init():
|
def init():
|
||||||
"""Initialise the local stats database tables
|
"""Initialise the local stats database tables
|
||||||
|
|
|
@ -7,10 +7,11 @@ import queue
|
||||||
import ckan.plugins as plugins
|
import ckan.plugins as plugins
|
||||||
|
|
||||||
from ckanext.googleanalytics.views import ga
|
from ckanext.googleanalytics.views import ga
|
||||||
|
from ckanext.googleanalytics.cli import get_commands
|
||||||
|
|
||||||
class GAMixinPlugin(plugins.SingletonPlugin):
|
class GAMixinPlugin(plugins.SingletonPlugin):
|
||||||
plugins.implements(plugins.IBlueprint)
|
plugins.implements(plugins.IBlueprint)
|
||||||
|
plugins.implements(plugins.IClick)
|
||||||
|
|
||||||
analytics_queue = queue.Queue()
|
analytics_queue = queue.Queue()
|
||||||
|
|
||||||
|
@ -18,3 +19,8 @@ class GAMixinPlugin(plugins.SingletonPlugin):
|
||||||
|
|
||||||
def get_blueprint(self):
|
def get_blueprint(self):
|
||||||
return [ga]
|
return [ga]
|
||||||
|
|
||||||
|
# IClick
|
||||||
|
|
||||||
|
def get_commands(self):
|
||||||
|
return get_commands()
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -27,8 +27,5 @@ setup(
|
||||||
[paste.paster_command]
|
[paste.paster_command]
|
||||||
loadanalytics = ckanext.googleanalytics.commands:LoadAnalytics
|
loadanalytics = ckanext.googleanalytics.commands:LoadAnalytics
|
||||||
initdb = ckanext.googleanalytics.commands:InitDB
|
initdb = ckanext.googleanalytics.commands:InitDB
|
||||||
[console_scripts]
|
|
||||||
ckanext-googleanalytics = ckanext.googleanalytics.cli:googleanalytics
|
|
||||||
|
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue