forked from scrapinghub/shub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool.py
More file actions
29 lines (25 loc) · 807 Bytes
/
Copy pathtool.py
File metadata and controls
29 lines (25 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import click, importlib
from shub.utils import missing_modules
def missingmod_cmd(modules):
modlist = ", ".join(modules)
@click.command(help="*DISABLED* - requires %s" % modlist)
@click.pass_context
def cmd(ctx):
click.echo("Error: '%s' command requires %s" % (ctx.info_name, modlist))
ctx.exit(1)
return cmd
@click.group(help="Scrapinghub command-line client")
def cli():
pass
module_deps = {
"deploy": ["scrapy", "setuptools"],
"login": [],
}
for command, modules in module_deps.iteritems():
m = missing_modules(*modules)
if m:
cli.add_command(missingmod_cmd(m), command)
else:
module_path = "shub." + command
command_module = importlib.import_module(module_path)
cli.add_command(command_module.cli, command)