<s> """<STR_LIT>""" <EOL> import logging <EOL> logger = logging . getLogger ( '<STR_LIT>' ) <EOL> class SLA ( object ) : <EOL> supported_sla_types = ( '<STR_LIT>' , '<STR_LIT:<>' , '<STR_LIT>' , '<STR_LIT:>>' , '<STR_LIT>' , '<STR_LIT:=>' ) <EOL> def __init__ ( self , metric , sub_metric , stat_name , threshold , sla_type ) : <EOL> if sla_type not in self . supported_sla_types : <EOL> logger . error ( '<STR_LIT>' + sla_type ) <EOL> return None <EOL> self . metric = metric <EOL> self . sub_metric = sub_metric <EOL> self . stat_name = stat_name <EOL> self . sla_type = sla_type <EOL> self . is_processed = False <EOL> self . threshold = None <EOL> self . display = None <EOL> if '<STR_LIT:%>' in threshold : <EOL> self . threshold = float ( threshold . translate ( None , '<STR_LIT:%>' ) ) <EOL> self . display = '<STR_LIT:%>' <EOL> else : <EOL> self . threshold = float ( threshold ) <EOL> self . display = '<STR_LIT>' <EOL> self . sla_passed = None <EOL> self . stat_value = None <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . stat_name , self . sub_metric , self . threshold , self . sla_type , <EOL> self . sla_passed , self . display ) <EOL> def get_csv_repr ( self ) : <EOL> return "<STR_LIT>" . format ( self . sub_metric , self . stat_name , self . threshold , self . sla_type , self . stat_value , self . sla_passed ) <EOL> def check_sla_passed ( self , stat_value ) : <EOL> if self . sla_type in ( '<STR_LIT>' , '<STR_LIT:<>' ) : <EOL> self . grade_lt ( stat_value ) <EOL> elif self . sla_type in ( '<STR_LIT>' , '<STR_LIT:>>' ) : <EOL> self . grade_gt ( stat_value ) <EOL> elif self . sla_type in ( '<STR_LIT>' , '<STR_LIT:=>' ) : <EOL> self . grade_eq ( stat_value ) <EOL> else : <EOL> logger . error ( '<STR_LIT>' ) <EOL> self . stat_value = stat_value <EOL> return self . sla_passed <EOL> def grade_lt ( self , stat_value ) : <EOL> self . is_processed = True <EOL> if stat_value >= self . threshold : <EOL> self . sla_passed = False <EOL> else : <EOL> self . sla_passed = True <EOL> def grade_gt ( self , stat_value ) : <EOL> self . is_processed = True <EOL> if stat_value <= self . threshold : <EOL> self . sla_passed = False <EOL> else : <EOL> self . sla_passed = True <EOL> def grade_eq ( self , stat_value ) : <EOL> self . is_processed = True <EOL> if stat_value == self . threshold : <EOL> self . sla_passed = True <EOL> else : <EOL> self . sla_passed = False </s>
