@@ -55,12 +55,12 @@ def __init__(self, condition_data, attributes, logger):
55
55
def _get_condition_json (self , index ):
56
56
""" Method to generate json for logging audience condition.
57
57
58
- Args:
59
- index: Index of the condition.
58
+ Args:
59
+ index: Index of the condition.
60
60
61
- Returns:
62
- String: Audience condition JSON.
63
- """
61
+ Returns:
62
+ String: Audience condition JSON.
63
+ """
64
64
condition = self .condition_data [index ]
65
65
condition_log = {
66
66
'name' : condition [0 ],
@@ -74,12 +74,12 @@ def _get_condition_json(self, index):
74
74
def is_value_type_valid_for_exact_conditions (self , value ):
75
75
""" Method to validate if the value is valid for exact match type evaluation.
76
76
77
- Args:
78
- value: Value to validate.
77
+ Args:
78
+ value: Value to validate.
79
79
80
- Returns:
81
- Boolean: True if value is a string, boolean, or number. Otherwise False.
82
- """
80
+ Returns:
81
+ Boolean: True if value is a string, boolean, or number. Otherwise False.
82
+ """
83
83
# No need to check for bool since bool is a subclass of int
84
84
if isinstance (value , string_types ) or isinstance (value , (numbers .Integral , float )):
85
85
return True
@@ -194,29 +194,29 @@ def compare_user_version_with_target_version(self, index):
194
194
def exact_evaluator (self , index ):
195
195
""" Evaluate the given exact match condition for the user attributes.
196
196
197
- Args:
198
- index: Index of the condition to be evaluated.
197
+ Args:
198
+ index: Index of the condition to be evaluated.
199
199
200
- Returns:
201
- Boolean:
202
- - True if the user attribute value is equal (===) to the condition value.
203
- - False if the user attribute value is not equal (!==) to the condition value.
204
- None:
205
- - if the condition value or user attribute value has an invalid type.
206
- - if there is a mismatch between the user attribute type and the condition value type.
207
- """
200
+ Returns:
201
+ Boolean:
202
+ - True if the user attribute value is equal (===) to the condition value.
203
+ - False if the user attribute value is not equal (!==) to the condition value.
204
+ None:
205
+ - if the condition value or user attribute value has an invalid type.
206
+ - if there is a mismatch between the user attribute type and the condition value type.
207
+ """
208
208
condition_name = self .condition_data [index ][0 ]
209
209
condition_value = self .condition_data [index ][1 ]
210
210
user_value = self .attributes .get (condition_name )
211
211
212
212
if not self .is_value_type_valid_for_exact_conditions (condition_value ) or (
213
- self .is_value_a_number (condition_value ) and not validator .is_finite_number (condition_value )
213
+ self .is_value_a_number (condition_value ) and not validator .is_finite_number (condition_value )
214
214
):
215
215
self .logger .warning (audience_logs .UNKNOWN_CONDITION_VALUE .format (self ._get_condition_json (index )))
216
216
return None
217
217
218
218
if not self .is_value_type_valid_for_exact_conditions (user_value ) or not validator .are_values_same_type (
219
- condition_value , user_value
219
+ condition_value , user_value
220
220
):
221
221
self .logger .warning (
222
222
audience_logs .UNEXPECTED_TYPE .format (self ._get_condition_json (index ), type (user_value ), condition_name )
@@ -234,28 +234,28 @@ def exact_evaluator(self, index):
234
234
def exists_evaluator (self , index ):
235
235
""" Evaluate the given exists match condition for the user attributes.
236
236
237
- Args:
238
- index: Index of the condition to be evaluated.
237
+ Args:
238
+ index: Index of the condition to be evaluated.
239
239
240
- Returns:
241
- Boolean: True if the user attributes have a non-null value for the given condition,
242
- otherwise False.
243
- """
240
+ Returns:
241
+ Boolean: True if the user attributes have a non-null value for the given condition,
242
+ otherwise False.
243
+ """
244
244
attr_name = self .condition_data [index ][0 ]
245
245
return self .attributes .get (attr_name ) is not None
246
246
247
247
def greater_than_evaluator (self , index ):
248
248
""" Evaluate the given greater than match condition for the user attributes.
249
249
250
- Args:
251
- index: Index of the condition to be evaluated.
250
+ Args:
251
+ index: Index of the condition to be evaluated.
252
252
253
- Returns:
254
- Boolean:
255
- - True if the user attribute value is greater than the condition value.
256
- - False if the user attribute value is less than or equal to the condition value.
257
- None: if the condition value isn't finite or the user attribute value isn't finite.
258
- """
253
+ Returns:
254
+ Boolean:
255
+ - True if the user attribute value is greater than the condition value.
256
+ - False if the user attribute value is less than or equal to the condition value.
257
+ None: if the condition value isn't finite or the user attribute value isn't finite.
258
+ """
259
259
condition_name = self .condition_data [index ][0 ]
260
260
condition_value = self .condition_data [index ][1 ]
261
261
user_value = self .attributes .get (condition_name )
0 commit comments