Don't use keyword arguments everywhere
authorPaul Crowley <paul@lshift.net>
Fri, 20 Feb 2009 11:38:19 +0000
changeset 48 f0cb7ad9e4ab
parent 47 ebcc230f21e4
child 49 a886ed5fec05
Don't use keyword arguments everywhere
src/ruleset.py
--- a/src/ruleset.py	Fri Feb 20 11:37:58 2009 +0000
+++ b/src/ruleset.py	Fri Feb 20 11:38:19 2009 +0000
@@ -39,7 +39,7 @@
 
 def rule(pairs):
     matchers = [(k, globmatcher(v)) for k, v in pairs]
-    def c(**kw):
+    def c(kw):
         for k, m in matchers:
             if k not in kw or not m(kw[k]):
                 return False
@@ -52,25 +52,25 @@
     levels = ["init", "write", "read", "deny"]
 
     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):
+    def matchrule(self, kw):
         d = self.preset.copy()
-        d.update(**kw)
+        d.update(kw)
         for a, c in self.rules:
-            if c(**d):
+            if c(d):
                 return a
         return None
 
     def allow(self, level, **kw):
-        a = self.matchrule(**kw)
+        a = self.matchrule(kw)
         return a in self.levels and self.levels.index(a) <= self.levels.index(level)
     
     def readfile(self, fn):