From: Tomas Gavenciak Date: Sat, 29 May 2010 15:57:26 +0000 (-0400) Subject: Fixed minor bug in conf condition eval X-Git-Tag: python-dummy-working~52 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=7d74aca4dc92382a97e2f94b06c07382cb18edbf;p=eval.git Fixed minor bug in conf condition eval Fixed mismatch of params of eval(cl, depth) --- diff --git a/t/moe/conf.py b/t/moe/conf.py index 538f989..9d697af 100644 --- a/t/moe/conf.py +++ b/t/moe/conf.py @@ -103,7 +103,7 @@ class ConfigElem(object): "Caching helper calling self.evaluate(), returns a value or throws an exception." check_depth(depth) if not self.cached: - self.cached_val = self.evaluate(depth+1) + self.cached_val = self.evaluate(depth=depth+1) self.cached = True if self.cached_val == None: raise ConfigError("Unable to evaluate %r."%(self.name,)) @@ -157,15 +157,15 @@ class ConfigCondition(ConfigElem): if self.parent and not self.parent.value(): return False if cl[0] in ['==','!=']: - v = cl[1].evaluate(depth+1) == cl[2].evaluate(depth+1) + v = cl[1].evaluate(depth=depth+1) == cl[2].evaluate(depth=depth+1) if cl[0] == '!=': v = not v return v - v1 = self.evaluate(cl[1], depth+1) + v1 = self.evaluate(cl=cl[1], depth=depth+1) if cl[0] == 'NOT': return not v1 if cl[0] == 'OR' and v1: return True if cl[0] == 'AND' and not v1: return False - return self.evaluate(cl[2], depth+1) + return self.evaluate(cl=cl[2], depth=depth+1) def formula_string(self, formula): "Create a string representation of a formula." if formula[0] == 'AND': @@ -260,7 +260,7 @@ class ConfigVar(ConfigElem): op = self.operations[i] # Check the guarding condition if (not op.condition) or op.condition.value(depth+1): - val.insert(0, op.expression.evaluate(depth+1)) + val.insert(0, op.expression.evaluate(depth=depth+1)) if op.operation == 'SET': return u''.join(val) return None