def load_plugins(plugin_manager, *paths): """Return the list of core plugins and load those from the given paths. note:: by default hooks are called in LIFO registered order thus plugins register order may be important. """ plugins = [] for path in paths: plugin = load_module(path) if plugin: LOGGER.info("Plugin '%s' loaded", path) plugins.append(plugin) plugins += [ ViewPlugin(plugin_manager), # Last called PrinterPlugin(plugin_manager), PicturePlugin(plugin_manager), CameraPlugin(plugin_manager), LightsPlugin(plugin_manager) ] # First called for plugin in plugins: plugin_manager.register(plugin) # Check that each hookimpl is defined in the hookspec # except for hookimpl with kwarg ``optionalhook=True``. plugin_manager.check_pending()
def load_plugins(plugin_manager, *paths): """Return the list of core plugins and load those from the given paths. note:: by default hooks are called in LIFO registered order thus plugins register order may be important. :param plugin_manager: plugins manager instance :type plugin_manager: :py:class:`pluggy.PluginManager` :param paths: list of Python module paths to load :type paths: str """ plugins = [] for path in paths: plugin = load_module(path) if plugin: LOGGER.debug("Plugin found at '%s'", path) plugins.append(plugin) plugins += [LightsPlugin(plugin_manager), # Last called ViewPlugin(plugin_manager), PrinterPlugin(plugin_manager), PicturePlugin(plugin_manager), CameraPlugin(plugin_manager)] # First called for plugin in plugins: plugin_manager.register(plugin) # Check that each hookimpl is defined in the hookspec # except for hookimpl with kwarg ``optionalhook=True``. plugin_manager.check_pending()
def load_all_plugins(self, paths, disabled=None): """Register the core plugins, load plugins from setuptools entry points and the load given module/package paths. note:: by default hooks are called in LIFO registered order thus plugins register order is important. :param paths: list of Python module/package paths to load :type paths: list :param disabled: list of plugins name to be disabled after loaded :type disabled: list """ # Load plugins declared by setuptools entry points self.load_setuptools_entrypoints(hookspecs.hookspec.project_name) plugins = [] for path in paths: plugin = load_module(path) if plugin: LOGGER.debug("Plugin found at '%s'", path) plugins.append(plugin) plugins += [ LightsPlugin(self), # Last called ViewPlugin(self), PrinterPlugin(self), PicturePlugin(self), CameraPlugin(self) ] # First called for plugin in plugins: self.register(plugin) # Check that each hookimpl is defined in the hookspec # except for hookimpl with kwarg 'optionalhook=True'. self.check_pending() # Disable unwanted plugins if disabled: for name in disabled: self.unregister(name=name)