Commit b522b7aa authored by Valentin Samir's avatar Valentin Samir

[filter2] Possibilité d'utiliser des < ou > dans les filtres humains

parent 72e35bcb
......@@ -21,7 +21,7 @@ def prioritize(l):
if not isinstance(l, list):
return l
l=simplify(l)
for c in ['!=', '=', '&', '|']:
for c in ['!=', '<', '>', '=', '&', '|']:
i=0
while i<len(l):
if l[i] == c:
......@@ -51,6 +51,10 @@ def toldapfilter(l):
op=l[0]
if op == "=":
return "%s=%s" % (l[1], l[2])
elif op == "<":
return "!(%s>=%s)" % (l[1], l[2])
elif op == ">":
return "!(%s<=%s)" % (l[1], l[2])
elif op == "!=":
return "!(%s=%s)" % (l[1], l[2])
return op + ''.join(['(%s)' % toldapfilter(i) for i in l[1:]])
......@@ -63,8 +67,8 @@ def pypexpr():
if not expr:
import pyparsing
unicodePrintables = u''.join(unichr(c) for c in xrange(65536) if not unichr(c).isspace())
txt = "".join(c for c in unicodePrintables if c not in '()&|!=')
expr = pyparsing.nestedExpr("(", ")", pyparsing.Word(txt) | pyparsing.oneOf("& | != ="))
txt = "".join(c for c in unicodePrintables if c not in '()&|<>!=')
expr = pyparsing.nestedExpr("(", ")", pyparsing.Word(txt) | pyparsing.oneOf("& | < > != ="))
return expr
def human_to_list(data):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment