More robust plugin list in conf
A single plugin name or an absence of it, with or without comma, is now properly handled. Related: #18
This commit is contained in:
parent
f843aebcbd
commit
aa521576f5
@ -68,8 +68,9 @@ pages = string(default='')
|
||||
|
||||
|
||||
[plugins]
|
||||
# comma-separated list of the plugins to load
|
||||
active = list(default=list())
|
||||
# Comma-separated list of the plugins to load.
|
||||
# The only current available plugin is alias.
|
||||
active = force_list(default=list('alias'))
|
||||
|
||||
[[alias]]
|
||||
# new subcommands can be defined, e.g.:
|
||||
|
@ -35,21 +35,22 @@ def load_plugins(conf, ui):
|
||||
PapersPlugin subclasses desired.
|
||||
"""
|
||||
for name in conf['plugins']['active']:
|
||||
modname = '%s.%s.%s.%s' % ('pubs', PLUGIN_NAMESPACE, name, name)
|
||||
try:
|
||||
namespace = importlib.import_module(modname)
|
||||
except ImportError as exc:
|
||||
# Again, this is hacky:
|
||||
if exc.args[0].endswith(' ' + name):
|
||||
ui.warning('plugin {} not found'.format(name))
|
||||
if len(name) > 0:
|
||||
modname = '{}.{}.{}.{}'.format('pubs', PLUGIN_NAMESPACE, name, name)
|
||||
try:
|
||||
namespace = importlib.import_module(modname)
|
||||
except ImportError as exc:
|
||||
# Again, this is hacky:
|
||||
if exc.args[0].endswith(' ' + name):
|
||||
ui.warning('plugin {} not found'.format(name))
|
||||
else:
|
||||
raise
|
||||
else:
|
||||
raise
|
||||
else:
|
||||
for obj in namespace.__dict__.values():
|
||||
if isinstance(obj, type) and issubclass(obj, PapersPlugin) \
|
||||
and obj != PapersPlugin:
|
||||
_classes.append(obj)
|
||||
_instances[obj] = obj(conf)
|
||||
for obj in namespace.__dict__.values():
|
||||
if isinstance(obj, type) and issubclass(obj, PapersPlugin) \
|
||||
and obj != PapersPlugin:
|
||||
_classes.append(obj)
|
||||
_instances[obj] = obj(conf)
|
||||
|
||||
|
||||
def get_plugins():
|
||||
|
Loading…
x
Reference in New Issue
Block a user