]> jfr.im git - erebus.git/blob - modlib.py
Starting module API
[erebus.git] / modlib.py
1 class modlib(object):
2 hooks = {}
3 parent = None
4
5 def __init__(self, name):
6 self.name = name
7
8 def modstart(self, parent):
9 self.parent = parent
10 for cmd, func in self.hooks.iteritems():
11 self.parent.hook(cmd, func)
12
13 def hook(self, cmd):
14 def realhook(func):
15 self.hooks[cmd] = func
16 if self.parent is not None:
17 self.parent.hook(cmd, func)
18 return func
19 return realhook