56 lines
968 B
Python
56 lines
968 B
Python
#! /usr/bin/python
|
|
|
|
# To change this template, choose Tools | Templates
|
|
# and open the template in the editor.
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Mar 14, 2010 3:06:37 PM$"
|
|
|
|
import re
|
|
import sys
|
|
|
|
import ocarina
|
|
|
|
from ct.message import write
|
|
from ct import path
|
|
from ct.dict import Dict
|
|
|
|
|
|
class PlManager(Dict):
|
|
def __init__(self):
|
|
Dict.__init__(self)
|
|
write("Creating Plugin Manager",1)
|
|
#self.plugins = dict()
|
|
|
|
|
|
def load(self, name):
|
|
write("Importing plugin: "+name, 2)
|
|
__import__(name)
|
|
plugin = sys.modules[name].Plugin()
|
|
plugin.enabled = True
|
|
self[name] = plugin
|
|
|
|
|
|
def run(self,name,args=None):
|
|
if self[name].enabled == True:
|
|
if args == None:
|
|
args = []
|
|
else:
|
|
args = args.split()
|
|
return self[name].start(args)
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def init():
|
|
ocarina.plugins = PlManager()
|
|
|
|
for p in ocarina.vars["$path"].split(":"):
|
|
for mod in path.addPyPath(p):
|
|
ocarina.plugins.load(mod)
|
|
|
|
|
|
ocarina.events.invite("ocarina-start",init,5)
|
|
|