def test_get_plugin(self): p_name = _TestPlugin.name # Test if _TestPlugin is available self.assertTrue(p_name in self._manager.available_plugins_names) # Test getting _TestPlugin plugin = self._manager.get_plugin(_TestPlugin.name) self.assertTrue(isinstance(plugin, _TestPlugin)) self.assertTrue(IPlugin.providedBy(plugin)) # Test getting an inexistent plugin self.assertRaises(PluginError, self._manager.get_plugin, '_null_')
def register_plugin(self, plugin): """Registers a plugin on manager This needs to be called by every plugin, or else, the manager won't know it's existence. It's usually a good idea to use :class:`register_plugin` function on plugin code, so the plugin will be registered as soon as it's module gets read by python. :param plugin: the :class:`IPlugin` implementation of the plugin """ if not IPlugin.providedBy(plugin): raise TypeError("The object %s does not implement IPlugin " "interface" % (plugin, )) self._plugins[plugin.name] = plugin
def register_plugin(self, plugin): """Registers a plugin on manager This needs to be called by every plugin, or else, the manager won't know it's existence. It's usually a good idea to use :class:`register_plugin` function on plugin code, so the plugin will be registered as soon as it's module gets read by python. :param plugin: the :class:`IPlugin` implementation of the plugin """ if not IPlugin.providedBy(plugin): raise TypeError("The object %s does not implement IPlugin " "interface" % (plugin, )) self._plugins[plugin.name] = plugin if library.uninstalled: gladedir = os.path.join('plugins', plugin.name, 'glade') if os.path.exists(gladedir): library.add_global_resource('glade', gladedir)