rules.py
changeset 21 59540181a4bb
parent 18 538d6b198f4a
--- 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
-
-