Added "or_" and "and_" query operators
authorThierry Florac <thierry.florac@onf.fr>
Wed, 15 Apr 2015 14:32:55 +0200
changeset 3 7c6f10ffdda0
parent 2 959d098e49d9
child 4 1f4b299e041c
Added "or_" and "and_" query operators
src/pyams_catalog/query.py
--- a/src/pyams_catalog/query.py	Wed Apr 15 14:32:28 2015 +0200
+++ b/src/pyams_catalog/query.py	Wed Apr 15 14:32:55 2015 +0200
@@ -38,3 +38,21 @@
             query = query[1]
         for oid in query:
             yield self.intids.queryObject(oid)
+
+
+def or_(source, added):
+    """Combine two queries with 'or'"""
+    if source is None:
+        source = added
+    else:
+        source |= added
+    return source
+
+
+def and_(source, added):
+    """Combine two queries with 'and'"""
+    if source is None:
+        source = added
+    else:
+        source &= added
+    return source