#NEWLINE# def lowest_rate( self , carriers = None , services = None ) : #NEWLINE# #INDENT# carriers = ( carriers or [ ] ) #NEWLINE# services = ( services or [ ] ) #NEWLINE# lowest_rate = None #NEWLINE# try : #NEWLINE# #INDENT# carriers = carriers . split ( ',' ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# carriers = [ c . lower ( ) for c in carriers ] #NEWLINE# try : #NEWLINE# #INDENT# services = services . split ( ',' ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# services = [ service . lower ( ) for service in services ] #NEWLINE# for rate in self . rates : #NEWLINE# #INDENT# rate_carrier = rate . carrier . lower ( ) #NEWLINE# if ( ( len ( self ) > 0 ) and ( rate_carrier not in carriers ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# rate_service = rate . service . lower ( ) #NEWLINE# if ( ( len ( services ) > 0 ) and ( rate_service not in services ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( ( lowest_rate is None ) or ( float ( rate . rate ) < float ( lowest_rate . rate ) ) ) : #NEWLINE# #INDENT# lowest_rate = rate #NEWLINE# #UNINDENT# #UNINDENT# if ( lowest_rate is None ) : #NEWLINE# #INDENT# raise Error ( 'No rates found.' ) #NEWLINE# #UNINDENT# return lowest_rate