diff -r f4daa224dc7e -r 59540181a4bb rules.py --- a/rules.py Tue Apr 22 10:13:39 2008 +0100 +++ b/rules.py Tue Apr 22 10:20:47 2008 +0100 @@ -50,13 +50,20 @@ def __init__(self): self.rules = [] + self.preset = {} def add(self, action, conditions): self.rules.append((action, conditions)) + + def set(self, **kw): + self.preset.update(kw) + def matchrule(self, **kw): + d = self.preset.copy() + d.update(**kw) for a, c in self.rules: - if c(**kw): + if c(**d): return a return None @@ -77,5 +84,3 @@ finally: f.close() return res - -