INNER CODE UNIT · Python
register_extension
python-bonobo/bonobo · bonobo/commands/__init__.py:30
def register_extension(ext):
nonlocal commands
try:
parser = subparsers.add_parser(ext.name)
if isinstance(ext.plugin, type) and issubclass(ext.plugin, BaseCommand):
# current way, class based.
cmd = ext.plugin()
cmd.add_arguments(parser)
cmd.__name__ = ext.name
commands[ext.name] = cmd.handle
else:
# old school, function based.
commands[ext.name] = ext.plugin(parser)
except Exception:
logger.exception("Error while loading command {}.".format(ext.name))
from stevedore import ExtensionManager