def init_plugins(self): self.plugins = [] for plugin in load_plugins(self.settings): name = get_plugin_name(plugin) logger.debug('Registering plugin `%s`', name) try: plugin.register() self.plugins.append(plugin) except Exception as e: logger.error('Cannot register plugin `%s`\n%s', name, e) self.settings['PLUGINS'] = [get_plugin_name(p) for p in self.plugins]
def test_get_plugin_name(self): self.assertEqual( get_plugin_name(normal_plugin), 'pelican.tests.dummy_plugins.normal_plugin.normal_plugin', ) class NoopPlugin: def register(self): pass self.assertEqual( get_plugin_name(NoopPlugin), 'PluginTest.test_get_plugin_name.<locals>.NoopPlugin') self.assertEqual( get_plugin_name(NoopPlugin()), 'PluginTest.test_get_plugin_name.<locals>.NoopPlugin')
def get_plugin_names(plugins): return {get_plugin_name(p) for p in plugins}