From fae7760125e5208648af8d8868a1f8a4c604a3c5 Mon Sep 17 00:00:00 2001 From: CyclingNinja Date: Thu, 4 Apr 2024 21:32:01 +0100 Subject: [PATCH] Refactor to plugins_to_require / load --- glue/main.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/glue/main.py b/glue/main.py index b47d15a2c..01cd10f15 100755 --- a/glue/main.py +++ b/glue/main.py @@ -10,7 +10,7 @@ _installed_plugins = set() -def load_plugins(splash=None, require_qt_plugins=False, plugins_to_use=None): +def load_plugins(splash=None, require_qt_plugins=False, plugins_to_load=None): """ Parameters @@ -19,7 +19,7 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_use=None): instance of splash http rendering service require_qt_plugins : boolean default: False whether to use qt plugins defined in constant REQUIRED_PLUGINS_QT - plugins_to_use : list + plugins_to_load : list desired valid plugin strings Returns @@ -48,17 +48,18 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_use=None): from glue._plugin_helpers import iter_plugin_entry_points, PluginConfig config = PluginConfig.load() - n_plugins = len(list(iter_plugin_entry_points())) - if plugins_to_use is None: + if plugins_to_load is None: + plugins_to_load = list(iter_plugin_entry_points()) if require_qt_plugins: - plugins_to_use = [*REQUIRED_PLUGINS, *REQUIRED_PLUGINS_QT] + plugins_to_require = [*REQUIRED_PLUGINS, *REQUIRED_PLUGINS_QT] else: - plugins_to_use = REQUIRED_PLUGINS + plugins_to_require = REQUIRED_PLUGINS else: - n_plugins = len(plugins_to_use) + plugins_to_require = plugins_to_load + n_plugins = len(plugins_to_require) for i_plugin, item in enumerate(list(iter_plugin_entry_points())): - if item.value.replace(':setup', '') in plugins_to_use: + if item.value.replace(':setup', '') in plugins_to_load: if item.module not in _installed_plugins: _installed_plugins.add(item.name) @@ -91,9 +92,7 @@ def load_plugins(splash=None, require_qt_plugins=False, plugins_to_use=None): except Exception as exc: # Here we check that some of the 'core' plugins load well and # raise an actual exception if not. - if item.module in REQUIRED_PLUGINS: - raise - elif item.module in REQUIRED_PLUGINS_QT and require_qt_plugins: + if item.module in plugins_to_require: raise else: logger.info("Loading plugin {0} failed "