mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Extracted loadPlugin{Module,Class} behavior into separate functions that can be exported to all modules.
This commit is contained in:
parent
411289e625
commit
a765308cbd
@ -52,6 +52,18 @@ import drivers
|
|||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
|
def loadPluginModule(name):
|
||||||
|
moduleInfo = imp.find_module(name, conf.pluginDirs)
|
||||||
|
module = imp.load_module(name, *moduleInfo)
|
||||||
|
linecache.checkcache()
|
||||||
|
return module
|
||||||
|
|
||||||
|
def loadPluginClass(irc, module):
|
||||||
|
callback = module.Class()
|
||||||
|
irc.addCallback(callback)
|
||||||
|
if hasattr(callback, 'configure'):
|
||||||
|
callback.configure(irc)
|
||||||
|
|
||||||
class OwnerCommands(privmsgs.CapabilityCheckingPrivmsg):
|
class OwnerCommands(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
priority = ~sys.maxint # This must be first!
|
priority = ~sys.maxint # This must be first!
|
||||||
capability = 'owner'
|
capability = 'owner'
|
||||||
@ -208,16 +220,11 @@ class OwnerCommands(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
irc.error(msg, 'That module is already loaded.')
|
irc.error(msg, 'That module is already loaded.')
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
moduleInfo = imp.find_module(name, conf.pluginDirs)
|
module = loadPluginModule(name)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
irc.error(msg, 'No plugin %s exists.' % name)
|
irc.error(msg, 'No plugin %s exists.' % name)
|
||||||
return
|
return
|
||||||
module = imp.load_module(name, *moduleInfo)
|
loadPluginClass(irc, module)
|
||||||
linecache.checkcache()
|
|
||||||
callback = module.Class()
|
|
||||||
irc.addCallback(callback)
|
|
||||||
if hasattr(callback, 'configure'):
|
|
||||||
callback.configure(irc)
|
|
||||||
irc.reply(msg, conf.replySuccess)
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user