From cb4ac3ca184fb1ba4c1b034bc95c72843e64a4cb Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sun, 17 Nov 2013 16:38:34 +0100 Subject: [PATCH] =?UTF-8?q?D'autre=20fa=C3=A7ons=20de=20fournir=20human=5F?= =?UTF-8?q?to=5Fldap=20pour=20les=20filtres=20de=20recherches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filter2.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ filter3.py | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 filter2.py create mode 100644 filter3.py diff --git a/filter2.py b/filter2.py new file mode 100644 index 0000000..4af8680 --- /dev/null +++ b/filter2.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +"""Plus rapide""" + +import pyparsing + +def simplify(l): + if not isinstance(l, list): + return l + if len(l) == 1: + return simplify(l[0]) + else: + return [simplify(i) for i in l] + +def toprefix(l): + if not isinstance(l, list): + return l + op=l[1] + args=[toprefix(i) for i in l if i!=op] + return [op]+args + +def prioritize(l): + if not isinstance(l, list): + return l + l=simplify(l) + for c in ['!=', '=', '&', '|']: + i=0 + while i