reduced unnecessary loop in cryptobox.plugins.manage to remove duplicate log entries

This commit is contained in:
lars 2007-01-08 02:21:16 +00:00
parent e38d566088
commit d9d28d2c58

View file

@ -60,23 +60,20 @@ class PluginManager:
"""
plist = []
for plfile in self.__get_plugin_files():
plist.append(self.__get_plugin_class(os.path.basename(plfile)[:-3]))
plist.append(self.__get_plugin_class(plfile))
return plist
def __get_plugin_class(self, name):
def __get_plugin_class(self, plfile):
"""Return a instance object of the give feature.
"""
import imp
for plfile in self.__get_plugin_files():
if name == os.path.basename(plfile)[:-3]:
try:
pl_class = getattr(imp.load_source(name, plfile), name)
except AttributeError:
return None
return pl_class(self.cbox, os.path.dirname(plfile), self.site)
else:
name = os.path.basename(plfile)[:-3]
try:
pl_class = getattr(imp.load_source(name, plfile), name)
except AttributeError:
return None
return pl_class(self.cbox, os.path.dirname(plfile), self.site)
def __get_plugin_files(self):
@ -93,7 +90,7 @@ class PluginManager:
if plname in disabled:
if self.cbox:
self.cbox.log.info(
"skipped plugin '%s' (disabled via config)" % plname)
"Skipping plugin '%s' (disabled via config)" % plname)
continue
pldir = os.path.join(pdir, plname)
plfile = os.path.join(pldir, plname + ".py")