Simpler package generation using cookiecutter, stdout buffering for consoleplugin

This commit is contained in:
Romain Dorgueil
2017-05-27 14:55:25 +02:00
parent 34aa357fd3
commit eacf52aaf6
11 changed files with 114 additions and 66 deletions

View File

@ -1,9 +1,31 @@
import bonobo
from bonobo.util.packages import bonobo_packages
def execute():
print('{} v.{}'.format(bonobo.__name__, bonobo.__version__))
def format_version(mod, *, name=None, quiet=False):
return ('{name} {version}' if quiet else '{name} v.{version} (in {location})').format(
name=name or mod.__name__,
version=mod.__version__,
location=bonobo_packages[name or mod.__name__].location
)
def execute(all=False, quiet=False):
print(format_version(bonobo, quiet=quiet))
if all:
for name in sorted(bonobo_packages):
if name != 'bonobo':
try:
mod = __import__(name.replace('-', '_'))
try:
print(format_version(mod, name=name, quiet=quiet))
except Exception as exc:
print('{} ({})'.format(name, exc))
except ImportError as exc:
print('{} is not importable ({}).'.format(name, exc))
def register(parser):
parser.add_argument('--all', '-a', action='store_true')
parser.add_argument('--quiet', '-q', action='store_true')
return execute