Skip to content

Commit 91f5c0d

Browse files
author
Alejandro Casanovas
committed
Added negate to iterables inside Query
1 parent da4548e commit 91f5c0d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

O365/utils/utils.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ def endswith(self, word):
11151115

11161116
@fluent
11171117
def iterable(self, iterable_name, *, collection, word, attribute=None, func=None,
1118-
operation=None):
1118+
operation=None, negate=False):
11191119
""" Performs a filter with the OData 'iterable_name' keyword
11201120
on the collection
11211121
@@ -1134,6 +1134,7 @@ def iterable(self, iterable_name, *, collection, word, attribute=None, func=None
11341134
the collection
11351135
:param str operation: the logical operation to apply to the attribute
11361136
inside the collection
1137+
:param bool negate: negate the funcion or operation inside the iterable
11371138
:rtype: Query
11381139
"""
11391140

@@ -1156,9 +1157,9 @@ def iterable(self, iterable_name, *, collection, word, attribute=None, func=None
11561157
attribute = 'a/{}'.format(attribute)
11571158

11581159
if func is not None:
1159-
sentence = self._prepare_function(func, attribute, word)
1160+
sentence = self._prepare_function(func, attribute, word, negate)
11601161
else:
1161-
sentence = self._prepare_sentence(attribute, operation, word)
1162+
sentence = self._prepare_sentence(attribute, operation, word, negate)
11621163

11631164
filter_str, attrs = sentence
11641165

@@ -1170,7 +1171,7 @@ def iterable(self, iterable_name, *, collection, word, attribute=None, func=None
11701171
return self
11711172

11721173
@fluent
1173-
def any(self, *, collection, word, attribute=None, func=None, operation=None):
1174+
def any(self, *, collection, word, attribute=None, func=None, operation=None, negate=False):
11741175
""" Performs a filter with the OData 'any' keyword on the collection
11751176
11761177
For example:
@@ -1188,14 +1189,16 @@ def any(self, *, collection, word, attribute=None, func=None, operation=None):
11881189
inside the collection
11891190
:param str operation: the logical operation to apply to the
11901191
attribute inside the collection
1192+
:param bool negate: negate the funcion or operation inside the iterable
11911193
:rtype: Query
11921194
"""
11931195

11941196
return self.iterable('any', collection=collection, word=word,
1195-
attribute=attribute, func=func, operation=operation)
1197+
attribute=attribute, func=func, operation=operation,
1198+
negate=negate)
11961199

11971200
@fluent
1198-
def all(self, *, collection, word, attribute=None, func=None, operation=None):
1201+
def all(self, *, collection, word, attribute=None, func=None, operation=None, negate=False):
11991202
""" Performs a filter with the OData 'all' keyword on the collection
12001203
12011204
For example:
@@ -1213,11 +1216,13 @@ def all(self, *, collection, word, attribute=None, func=None, operation=None):
12131216
inside the collection
12141217
:param str operation: the logical operation to apply to the
12151218
attribute inside the collection
1219+
:param bool negate: negate the funcion or operation inside the iterable
12161220
:rtype: Query
12171221
"""
12181222

12191223
return self.iterable('all', collection=collection, word=word,
1220-
attribute=attribute, func=func, operation=operation)
1224+
attribute=attribute, func=func, operation=operation,
1225+
negate=negate)
12211226

12221227
@fluent
12231228
def order_by(self, attribute=None, *, ascending=True):

0 commit comments

Comments
 (0)