Plugln library: Fixed files check for the plugin loader

This commit is contained in:
Felipe Martín 2013-11-26 15:01:49 +01:00
parent bbcb3fe088
commit c20f0dc316
1 changed files with 9 additions and 1 deletions

View File

@ -13,6 +13,8 @@ class Library(object):
_instance = None
_plugins = {} # Plugin dictonary
_mandatory_plugin_files = ['__init__.py', 'plugin.py']
def register(self, plugin):
"""
Decorator to register plugins
@ -32,9 +34,15 @@ class Library(object):
def discover(self):
for path, dirs, files in walk(PATH):
if files == ['__init__.py', 'plugin.py']:
if self._is_plugin(files):
self.load(path)
@property
def plugins(self):
return self._plugins
def _is_plugin(self, files):
for f in self._mandatory_plugin_files:
if f not in files:
return False
return True