Fix the error message
This commit is contained in:
parent
78cfe65b2e
commit
c97f33633a
1 changed files with 10 additions and 6 deletions
|
|
@ -25,29 +25,34 @@ __all__ = ['ResultsCondition', 'ResultsConditionError']
|
||||||
|
|
||||||
|
|
||||||
class Condition(object):
|
class Condition(object):
|
||||||
def __init__(self, left, op, right):
|
def __init__(self, left, op, right):
|
||||||
self.left = left # Field of the object to test
|
self.left = left # Field of the object to test
|
||||||
self.op = op
|
self.op = op
|
||||||
self.right = right
|
self.right = right
|
||||||
|
|
||||||
|
|
||||||
def is_egal(left, right):
|
def is_egal(left, right):
|
||||||
return left == right
|
return left == right
|
||||||
|
|
||||||
|
|
||||||
def is_notegal(left, right):
|
def is_notegal(left, right):
|
||||||
return left != right
|
return left != right
|
||||||
|
|
||||||
|
|
||||||
def is_sup(left, right):
|
def is_sup(left, right):
|
||||||
return left < right
|
return left < right
|
||||||
|
|
||||||
|
|
||||||
def is_inf(left, right):
|
def is_inf(left, right):
|
||||||
return left > right
|
return left > right
|
||||||
|
|
||||||
|
|
||||||
def is_in(left, right):
|
def is_in(left, right):
|
||||||
return left in right
|
return left in right
|
||||||
|
|
||||||
functions = {'!=': is_notegal, '=': is_egal, '>': is_sup, '<': is_inf, '|': is_in}
|
functions = {'!=': is_notegal, '=': is_egal, '>': is_sup, '<': is_inf, '|': is_in}
|
||||||
|
|
||||||
|
|
||||||
class ResultsCondition(IResultsCondition):
|
class ResultsCondition(IResultsCondition):
|
||||||
condition_str = None
|
condition_str = None
|
||||||
|
|
||||||
|
|
@ -66,14 +71,13 @@ class ResultsCondition(IResultsCondition):
|
||||||
operator = op
|
operator = op
|
||||||
break
|
break
|
||||||
if operator is None:
|
if operator is None:
|
||||||
raise ResultsConditionError(u'Could not find = or != operator in sub-expression "%s"' % _and)
|
raise ResultsConditionError(u'Could not find a valid operator in sub-expression "%s"' % _and)
|
||||||
l, r = _and.split(operator)
|
l, r = _and.split(operator)
|
||||||
and_list.append(Condition(l, operator, r))
|
and_list.append(Condition(l, operator, r))
|
||||||
or_list.append(and_list)
|
or_list.append(and_list)
|
||||||
self.condition = or_list
|
self.condition = or_list
|
||||||
self.condition_str = condition_str
|
self.condition_str = condition_str
|
||||||
|
|
||||||
|
|
||||||
def is_valid(self, obj):
|
def is_valid(self, obj):
|
||||||
d = dict(obj.iter_fields())
|
d = dict(obj.iter_fields())
|
||||||
# We evaluate all member of a list at each iteration.
|
# We evaluate all member of a list at each iteration.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue