diff --git a/openlp/core/pluginmanager.py b/openlp/core/pluginmanager.py index 7d042efb0..ec1a44dfd 100644 --- a/openlp/core/pluginmanager.py +++ b/openlp/core/pluginmanager.py @@ -51,18 +51,23 @@ class PluginManager(object): """ Scan the directory dir for objects inheriting from openlp.plugin """ - log.debug("find plugins " + str(dir)) + startdepth=len(os.path.abspath(dir).split(os.sep)) + log.debug("find plugins %s at depth %d" %( str(dir), startdepth)) + for root, dirs, files in os.walk(dir): for name in files: if name.endswith(".py") and not name.startswith("__"): path = os.path.abspath(os.path.join(root, name)) + thisdepth=len(path.split(os.sep)) + if thisdepth-startdepth > 2: # skip anything lower down + continue modulename, pyext = os.path.splitext(path) prefix = os.path.commonprefix([self.basepath, path]) # hack off the plugin base path modulename = modulename[len(prefix) + 1:] modulename = modulename.replace(os.path.sep, '.') # import the modules - log.debug("Importing %s from %s." % (modulename, path)) + log.debug("Importing %s from %s. Depth %d" % (modulename, path, thisdepth)) try: __import__(modulename, globals(), locals(), []) except ImportError, e: diff --git a/openlp/core/test/test_plugin_manager.py b/openlp/core/test/test_plugin_manager.py index 2d16484cd..bf04ec269 100644 --- a/openlp/core/test/test_plugin_manager.py +++ b/openlp/core/test/test_plugin_manager.py @@ -30,7 +30,7 @@ class TestPluginManager: # see which ones we've got assert ("testplugin1" in names) assert ("testplugin2" in names) - # and not got! + # and not got - it's too deep in the hierarchy! assert ("testplugin3" not in names) # test that the weighting is done right assert p.plugins[0].name=="testplugin2" diff --git a/openlp/core/test/testplugins/deeper/__init__.py b/openlp/core/test/testplugins/deeper/__init__.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/openlp/core/test/testplugins/deeper/__init__.py @@ -0,0 +1 @@ + diff --git a/openlp/core/test/testplugins/deeper/toodeep/__init__.py b/openlp/core/test/testplugins/deeper/toodeep/__init__.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/openlp/core/test/testplugins/deeper/toodeep/__init__.py @@ -0,0 +1 @@ + diff --git a/openlp/core/test/testplugins/deeper/toodeep/plugin3toodeep.py b/openlp/core/test/testplugins/deeper/toodeep/plugin3toodeep.py new file mode 100644 index 000000000..0f2d56d7a --- /dev/null +++ b/openlp/core/test/testplugins/deeper/toodeep/plugin3toodeep.py @@ -0,0 +1,13 @@ +from openlp.core.lib import Plugin +import logging + +class testplugin3toodeep(Plugin): + name="testplugin3" + version=0 + global log + log=logging.getLogger("testplugin1") + log.info("Started") + weight=10 + def __init__(self): + pass + diff --git a/openlp/core/test/testplugins/testplugin1.py b/openlp/core/test/testplugins/testplugin1.py index c681e00d2..1641817a4 100644 --- a/openlp/core/test/testplugins/testplugin1.py +++ b/openlp/core/test/testplugins/testplugin1.py @@ -7,7 +7,7 @@ class testplugin1(Plugin): global log log=logging.getLogger("testplugin1") log.info("Started") - Weight=10 + weight=10 def __init__(self): pass diff --git a/openlp/core/test/testplugins/testplugin2/testplugin2.py b/openlp/core/test/testplugins/testplugin2/testplugin2.py index 4956d80d3..c1687d2d9 100644 --- a/openlp/core/test/testplugins/testplugin2/testplugin2.py +++ b/openlp/core/test/testplugins/testplugin2/testplugin2.py @@ -3,6 +3,6 @@ from openlp.core.lib import Plugin class testplugin2(Plugin): name="testplugin2" version=1 - Weight=1 + weight=1 def __init__(self): pass