def load_plugins(scope=None):
scope = scope or PLUGIN_SCOPE_SERVICES
if PLUGINS_LOADED.get(scope, None):
return
setup_logging()
loaded_files = []
result = []
for module in pkgutil.iter_modules():
file_path = None
if six.PY3 and not isinstance(module, tuple):
file_path = '%s/%s/plugins.py' % (module.module_finder.path, module.name)
elif six.PY3 or isinstance(module[0], pkgutil.ImpImporter):
if hasattr(module[0], 'path'):
file_path = '%s/%s/plugins.py' % (module[0].path, module[1])
if file_path and file_path not in loaded_files:
plugin_config = load_plugin_from_path(file_path, scope=scope)
if plugin_config:
result.append(plugin_config)
loaded_files.append(file_path)
# set global flag
PLUGINS_LOADED[scope] = result
return result
# -----------------
# API ENTRY POINTS
# -----------------
评论列表
文章目录