From d9d28d2c581fe2c8c9ed7f0b8d63c7b18a502d31 Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 8 Jan 2007 02:21:16 +0000 Subject: [PATCH] reduced unnecessary loop in cryptobox.plugins.manage to remove duplicate log entries --- src/cryptobox/plugins/manage.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/cryptobox/plugins/manage.py b/src/cryptobox/plugins/manage.py index 78c7916..79c1838 100644 --- a/src/cryptobox/plugins/manage.py +++ b/src/cryptobox/plugins/manage.py @@ -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")