MCPcopy
hub / github.com/pyload/pyload / loadModule

Method loadModule

module/plugins/PluginManager.py:290–310  ·  view source on GitHub ↗

Returns loaded module for plugin :param type: plugin type, subfolder of module.plugins :param name:

(self, type, name)

Source from the content-addressed store, hash-verified

288 return name
289
290 def loadModule(self, type, name):
291 """ Returns loaded module for plugin
292
293 :param type: plugin type, subfolder of module.plugins
294 :param name:
295 """
296 plugins = self.plugins[type]
297 if name in plugins:
298 if "module" in plugins[name]: return plugins[name]["module"]
299 try:
300 module = __import__(self.ROOT + "%s.%s" % (type, plugins[name]["name"]), globals(), locals(),
301 plugins[name]["name"])
302 plugins[name]["module"] = module #cache import, maybe unneeded
303 return module
304 except Exception, e:
305 self.log.error(_("Error importing %(name)s: %(msg)s") % {"name": name, "msg": str(e)})
306 if self.core.debug:
307 print_exc()
308 else:
309 self.log.debug("Plugin %s not found" % name)
310 self.log.debug("Available plugins : %s" % str(plugins))
311
312 def loadClass(self, type, name):
313 """Returns the class of a plugin with the same name"""

Callers 4

getPluginMethod · 0.95
loadClassMethod · 0.95
init_pluginMethod · 0.80
activateMethod · 0.80

Calls 2

_Function · 0.50
errorMethod · 0.45

Tested by

no test coverage detected