]> jfr.im git - erebus.git/blob - modlib.py
Modules!
[erebus.git] / modlib.py
1 class modlib(object):
2 def __init__(self, name):
3 self.hooks = {}
4 self.parent = None
5
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 def modstop(self, parent):
13 for cmd, func in self.hooks.iteritems():
14 self.parent.unhook(cmd, func)
15
16 def hook(self, cmd):
17 def realhook(func):
18 self.hooks[cmd] = func
19 if self.parent is not None:
20 self.parent.hook(cmd, func)
21 return func
22 return realhook