コード例 #1
0
ファイル: __init__.py プロジェクト: catlee/lwr
def pluginFromDict(config, interface):
    """
    Instantiates a plugin from the given config dict
    The section must have a "plugin" option
    """
    plugin_name = config['plugin']

    if ':' in plugin_name:
        module_name, object_name = plugin_name.split(":", 1)
        plugin = load_plugin(module_name, object_name=object_name)
        return plugin(config)

    plugin = load_plugin(plugin_name, interface)
    return plugin(config)
コード例 #2
0
ファイル: test_plugins.py プロジェクト: catlee/lwr
 def test_load_module(self):
     p = load_plugin("lwr.plugins.dummy", EventStore)
     self.assertTrue(issubclass(p, EventStore))
コード例 #3
0
ファイル: test_plugins.py プロジェクト: catlee/lwr
 def test_load_file_byname(self):
     p = load_plugin(os.path.join(os.path.dirname(__file__), "../plugins/dummy/store.py"), object_name="DummyEventStore")
     self.assertTrue(issubclass(p, EventStore))
コード例 #4
0
ファイル: test_plugins.py プロジェクト: catlee/lwr
 def test_load_module_byname(self):
     p = load_plugin("lwr.plugins.dummy", object_name="DummyEventStore")
     self.assertTrue(issubclass(p, EventStore))
コード例 #5
0
ファイル: test_plugins.py プロジェクト: catlee/lwr
 def test_load_file_notfound(self):
     with self.assertRaises(ImportError):
         load_plugin(os.path.join(os.path.dirname(__file__), "../plugins/dummy/XXX.py"), EventStore)
コード例 #6
0
ファイル: test_plugins.py プロジェクト: catlee/lwr
 def test_load_module_notfound(self):
     with self.assertRaises(ImportError):
         load_plugin("lwr.plugins.XXX", EventStore)