Updated to work wit new directory structure and

plugin manager API

bzr-revno: 176
This commit is contained in:
Martin Thompson 2008-12-04 20:46:07 +00:00
parent afce6977c2
commit 1df73a768c
5 changed files with 15 additions and 9 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.pyc *.pyc
*.*~ *.*~
*.log *.log
\#*\#

View File

@ -18,22 +18,25 @@ import os, sys
mypath=os.path.split(os.path.abspath(__file__))[0] mypath=os.path.split(os.path.abspath(__file__))[0]
sys.path.insert(0,(os.path.join(mypath, '..' ,'..', '..'))) sys.path.insert(0,(os.path.join(mypath, '..' ,'..', '..')))
from openlp.plugins.plugin_manager import PluginManager from openlp.core.pluginmanager import PluginManager
# test the plugin manager with some plugins in the test_plugins directory
class TestPluginManager: class TestPluginManager:
def test_init(self): def test_init(self):
p=PluginManager("..") p=PluginManager("./testplugins")
assert (len(p.plugins)==2); assert (len(p.plugins)==2);
# get list of the names of the plugins # get list of the names of the plugins
names=[plugin.name for plugin in p.plugins] names=[plugin.name for plugin in p.plugins]
# see which ones we've got
assert ("testplugin1" in names) assert ("testplugin1" in names)
assert ("testplugin2" in names) assert ("testplugin2" in names)
# and not got!
assert ("testplugin3" not in names) assert ("testplugin3" not in names)
assert (p.plugin_by_name["testplugin1"].version==0) # test that the weighting is done right
assert (p.plugin_by_name["testplugin2"].version==1) assert p.plugins[0].name=="testplugin2"
assert p.plugins[1].name=="testplugin1"
if __name__=="__main__": if __name__=="__main__":
log.debug("Starting") log.debug("Starting")
p=PluginManager("..") p=PluginManager("./testplugins")
for plugin in p.plugins: for plugin in p.plugins:
log.debug("Plugin %s, name=%s (version=%d)"%(str(plugin), plugin.name, plugin.version)) log.debug("Plugin %s, name=%s (version=%d)"%(str(plugin), plugin.name, plugin.version))

View File

@ -1,4 +1,4 @@
from openlp.plugins import Plugin from openlp.core.lib import Plugin
import logging import logging
class testplugin1(Plugin): class testplugin1(Plugin):
@ -7,6 +7,7 @@ class testplugin1(Plugin):
global log global log
log=logging.getLogger("testplugin1") log=logging.getLogger("testplugin1")
log.info("Started") log.info("Started")
Weight=10
def __init__(self): def __init__(self):
pass pass

View File

@ -1,7 +1,8 @@
from openlp.plugins import Plugin from openlp.core.lib import Plugin
class testplugin2(Plugin): class testplugin2(Plugin):
name="testplugin2" name="testplugin2"
version=1 version=1
Weight=1
def __init__(self): def __init__(self):
pass pass