def regplugins(self): """ register plugins. """ self.regcore() avail = [] # check for myplugs directory if os.path.isdir('myplugs'): avail.extend(self.regdir('myplugs')) for i in os.listdir('myplugs'): if i.startswith('.'): continue if os.path.isdir('myplugs' + os.sep + i): avail.extend(self.regdir('myplugs' + os.sep + i)) else: rlog(10, 'plugins', 'no myplugs directory found') # check for gozerplugs package try: plugs = gozer_import('gozerplugs') except ImportError: rlog(20, 'plugins', "no gozerplugs package found") plugs = None if plugs: for i in plugs.__plugs__: if i not in avail: try: self.regplugin('gozerplugs', i) avail.append(i) except Exception, ex: handle_exception() else: rlog(10, 'plugins', '%s already loaded' % i)
def regcore(self): """ register core plugins. """ self.plugdeny.init([]) self.plugallow.init([]) avail = [] plugs = gozer_import('gozerbot.plugs') for i in plugs.__plugs__: if i not in avail: try: self.regplugin('gozerbot.plugs', i) except Exception, ex: handle_exception() avail.append(i)
def getdepend(self, plugname): """ get plugins the plugin depends on. """ # try to import the plugin if plugname in self.plugs: plug = self.plugs[plugname] else: for mod in ['gozerbot.plugs', 'gozerplugs', 'myplugs']: try: plug = gozer_import('%s.%s' % (mod, plugname)) except ImportError: continue # check for the __depend__ attribute try: depends = plug.__depend__ except: depends = [] return depends