@@ -62,7 +62,7 @@ def _check_not_empty(value, name, operation):
6262 :return: The result of validation
6363 :rtype: True|False
6464 """
65- if not value :
65+ if value . strip () == "" :
6666 _LOGGER .error ('{}: {} must not be empty.' .format (operation , name ))
6767 return False
6868 return True
@@ -108,7 +108,7 @@ def _check_can_convert(value, name, operation, message):
108108 if isinstance (value , six .string_types ):
109109 return True
110110 else :
111- if isinstance (value , bool ) or isinstance (value , Number ) is False :
111+ if isinstance (value , bool ) or ( not isinstance (value , Number )) :
112112 _LOGGER .error ('{}: {} {} {}' .format (operation , name , value , message ))
113113 return False
114114 _LOGGER .warning ('{}: {} {} is not of type string, converting.'
@@ -131,11 +131,11 @@ def _check_valid_matching_key(matching_key):
131131 'matchingKey with valid string properties.' )
132132 return False
133133 if isinstance (matching_key , six .string_types ):
134- if _check_not_empty (matching_key , 'matching_key' , 'get_treatment' ) is False :
134+ if not _check_not_empty (matching_key , 'matching_key' , 'get_treatment' ):
135135 return False
136136 else :
137- if _check_can_convert (matching_key , 'matching_key' , 'get_treatment' ,
138- 'has to be of type string.' ) is False :
137+ if not _check_can_convert (matching_key , 'matching_key' , 'get_treatment' ,
138+ 'has to be of type string.' ):
139139 return False
140140 return True
141141
@@ -153,8 +153,8 @@ def _check_valid_bucketing_key(bucketing_key):
153153 if bucketing_key is None :
154154 _LOGGER .warning ('get_treatment: Key object should have bucketingKey set.' )
155155 return None
156- if _check_can_convert (bucketing_key , 'bucketing_key' , 'get_treatment' ,
157- 'has to be of type string.' ) is False :
156+ if not _check_can_convert (bucketing_key , 'bucketing_key' , 'get_treatment' ,
157+ 'has to be of type string.' ):
158158 return False
159159 return str (bucketing_key )
160160
@@ -171,7 +171,7 @@ def validate_key(key):
171171 """
172172 matching_key_result = None
173173 bucketing_key_result = None
174- if _check_not_null (key , 'key' , 'get_treatment' ) is False :
174+ if not _check_not_null (key , 'key' , 'get_treatment' ):
175175 return None , None
176176 if isinstance (key , Key ):
177177 if _check_valid_matching_key (key .matching_key ):
@@ -198,8 +198,8 @@ def validate_feature_name(feature_name):
198198 :return: feature_name
199199 :rtype: str|None
200200 """
201- if _check_not_null (feature_name , 'feature_name' , 'get_treatment' ) is False or \
202- _check_is_string (feature_name , 'feature_name' , 'get_treatment' ) is False :
201+ if ( not _check_not_null (feature_name , 'feature_name' , 'get_treatment' )) or \
202+ ( not _check_is_string (feature_name , 'feature_name' , 'get_treatment' )) :
203203 return None
204204 return feature_name
205205
@@ -213,8 +213,8 @@ def validate_track_key(key):
213213 :return: key
214214 :rtype: str|None
215215 """
216- if _check_not_null (key , 'key' , 'track' ) is False or \
217- _check_can_convert (key , 'key' , 'track' , 'has to be of type string.' ) is False :
216+ if ( not _check_not_null (key , 'key' , 'track' )) or \
217+ ( not _check_can_convert (key , 'key' , 'track' , 'has to be of type string.' )) :
218218 return None
219219 return str (key )
220220
@@ -228,9 +228,9 @@ def validate_traffic_type(traffic_type):
228228 :return: traffic_type
229229 :rtype: str|None
230230 """
231- if _check_not_null (traffic_type , 'traffic_type' , 'track' ) is False or \
232- _check_is_string (traffic_type , 'traffic_type' , 'track' ) is False or \
233- _check_not_empty (traffic_type , 'traffic_type' , 'track' ) is False :
231+ if ( not _check_not_null (traffic_type , 'traffic_type' , 'track' )) or \
232+ ( not _check_is_string (traffic_type , 'traffic_type' , 'track' )) or \
233+ ( not _check_not_empty (traffic_type , 'traffic_type' , 'track' )) :
234234 return None
235235 return traffic_type
236236
@@ -244,10 +244,10 @@ def validate_event_type(event_type):
244244 :return: event_type
245245 :rtype: str|None
246246 """
247- if _check_not_null (event_type , 'event_type' , 'track' ) is False or \
248- _check_is_string (event_type , 'event_type' , 'track' ) is False or \
249- _check_pattern_match (event_type , 'event_type' , 'track' ,
250- r'[a-zA-Z0-9][-_\.a-zA-Z0-9]{0,62}' ) is False :
247+ if ( not _check_not_null (event_type , 'event_type' , 'track' )) or \
248+ ( not _check_is_string (event_type , 'event_type' , 'track' )) or \
249+ ( not _check_pattern_match (event_type , 'event_type' , 'track' ,
250+ r'[a-zA-Z0-9][-_\.a-zA-Z0-9]{0,62}' )) :
251251 return None
252252 return event_type
253253
@@ -263,7 +263,7 @@ def validate_value(value):
263263 """
264264 if value is None :
265265 return None
266- if not isinstance (value , Number ) or isinstance (value , bool ):
266+ if ( not isinstance (value , Number ) ) or isinstance (value , bool ):
267267 _LOGGER .error ('track: value must be a number.' )
268268 return False
269269 return value
@@ -278,7 +278,7 @@ def validate_manager_feature_name(feature_name):
278278 :return: feature_name
279279 :rtype: str|None
280280 """
281- if _check_not_null (feature_name , 'feature_name' , 'split' ) is False or \
282- _check_is_string (feature_name , 'feature_name' , 'split' ) is False :
281+ if ( not _check_not_null (feature_name , 'feature_name' , 'split' )) or \
282+ ( not _check_is_string (feature_name , 'feature_name' , 'split' )) :
283283 return None
284284 return feature_name
0 commit comments