reduced unnecessary loop in cryptobox.plugins.manage to remove duplicate log entries
This commit is contained in:
parent
e38d566088
commit
d9d28d2c58
|
@ -60,23 +60,20 @@ class PluginManager:
|
||||||
"""
|
"""
|
||||||
plist = []
|
plist = []
|
||||||
for plfile in self.__get_plugin_files():
|
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
|
return plist
|
||||||
|
|
||||||
|
|
||||||
def __get_plugin_class(self, name):
|
def __get_plugin_class(self, plfile):
|
||||||
"""Return a instance object of the give feature.
|
"""Return a instance object of the give feature.
|
||||||
"""
|
"""
|
||||||
import imp
|
import imp
|
||||||
for plfile in self.__get_plugin_files():
|
name = os.path.basename(plfile)[:-3]
|
||||||
if name == os.path.basename(plfile)[:-3]:
|
try:
|
||||||
try:
|
pl_class = getattr(imp.load_source(name, plfile), name)
|
||||||
pl_class = getattr(imp.load_source(name, plfile), name)
|
except AttributeError:
|
||||||
except AttributeError:
|
|
||||||
return None
|
|
||||||
return pl_class(self.cbox, os.path.dirname(plfile), self.site)
|
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
return pl_class(self.cbox, os.path.dirname(plfile), self.site)
|
||||||
|
|
||||||
|
|
||||||
def __get_plugin_files(self):
|
def __get_plugin_files(self):
|
||||||
|
@ -93,7 +90,7 @@ class PluginManager:
|
||||||
if plname in disabled:
|
if plname in disabled:
|
||||||
if self.cbox:
|
if self.cbox:
|
||||||
self.cbox.log.info(
|
self.cbox.log.info(
|
||||||
"skipped plugin '%s' (disabled via config)" % plname)
|
"Skipping plugin '%s' (disabled via config)" % plname)
|
||||||
continue
|
continue
|
||||||
pldir = os.path.join(pdir, plname)
|
pldir = os.path.join(pdir, plname)
|
||||||
plfile = os.path.join(pldir, plname + ".py")
|
plfile = os.path.join(pldir, plname + ".py")
|
||||||
|
|
Loading…
Reference in a new issue