Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Loads modules from the plugins directory
- def loadmods(self,mods,reload=0):
- sys.defaultpath=sys.path
- sys.path=[]
- sys.path.append(".\\plugins\\")
- x=""
- s=""
- for modname in mods:
- if self.cmds.has_key(modname):
- if reload==0:
- print "%s is already loaded." % (modname)
- else:
- print self.modclasses
- exec("s=reload(self.modclasses[\"%s\"])" % (modname))
- exec("x=s.%s" % (modname))
- self.cmds[modname]=x
- else:
- try:
- exec("import %s as s" % (modname))
- exec("x=s.%s" % (modname))
- self.modclasses[modname]=s
- self.cmds[modname]=x
- print "Loaded %s." % (modname)
- except ImportError:
- print "Could not load module %s." % (modname)
- sys.path=sys.defaultpath
- del sys.defaultpath
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement