summaryrefslogtreecommitdiffstats
path: root/module/plugins/PluginManager.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-12-22 23:45:38 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-12-22 23:45:38 +0100
commit958bf611f5d9d117f19f824990ec6fd6b537e967 (patch)
tree558cb45fa61b1738629dff9727c028badccd9990 /module/plugins/PluginManager.py
parentsome bugfixes (diff)
downloadpyload-958bf611f5d9d117f19f824990ec6fd6b537e967.tar.xz
accountmanager v2, delete your accounts.conf and re-enter them in pyload,
new nice debug functions, try core.shell() and core.breakpoint()
Diffstat (limited to 'module/plugins/PluginManager.py')
-rw-r--r--module/plugins/PluginManager.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py
index 9845590cf..5c31930a5 100644
--- a/module/plugins/PluginManager.py
+++ b/module/plugins/PluginManager.py
@@ -259,28 +259,28 @@ class PluginManager:
def findPlugin(self, name, pluginlist=("hoster", "crypter", "container")):
for ptype in pluginlist:
if name in self.plugins[ptype]:
- return self.plugins[ptype][name], ptype
+ return ptype, self.plugins[ptype][name]
return None, None
def getPlugin(self, name, original=False):
"""return plugin module from hoster|decrypter|container"""
- plugin, type = self.findPlugin(name)
+ type, plugin = self.findPlugin(name)
if not plugin:
self.log.warning("Plugin %s not found." % name)
- plugin = self.plugins["hoster"]["BasePlugin"]
+ name = "BasePlugin"
- if "new_module" in plugin and not original:
- return plugin["new_module"]
+ if (type, name) in self.modules and not original:
+ return self.modules[(type, name)]
return self.loadModule(type, name)
def getPluginName(self, name):
""" used to obtain new name if other plugin was injected"""
- plugin, type = self.findPlugin(name)
+ type, plugin = self.findPlugin(name)
- if "new_name" in plugin:
- return plugin["new_name"]
+ if (type, name) in self.names:
+ return self.names[(type, name)]
return name
@@ -309,10 +309,23 @@ class PluginManager:
module = self.loadModule(type, name)
if module: return getattr(module, name)
+ def hasAccountPlugin(self, plugin):
+ return plugin in self.plugins["accounts"]
+
def getAccountPlugins(self):
"""return list of account plugin names"""
return self.plugins["accounts"].keys()
+ def injectPlugin(self, type, name, module, new_name):
+ self.modules[(type, name)] = module
+ self.names[(type, name)] = new_name
+
+ def restoreState(self, type, name):
+ if (type, name) in self.modules:
+ del self.modules[(type, name)]
+ if (type, name) in self.names:
+ del self.names[(type, name)]
+
def find_module(self, fullname, path=None):
#redirecting imports if necesarry
if fullname.startswith(self.ROOT) or fullname.startswith(self.USERROOT): #seperate pyload plugins