#NEWLINE# def score_float( conn , tr_type , **kwargs ) : #NEWLINE# #INDENT# key_str = kwargs [ 'key_str' ] #NEWLINE# field_val = kwargs [ 'field_val' ] #NEWLINE# if ( tr_type . lower ( ) == 'insert' ) : #NEWLINE# #INDENT# def incrbyfloat( pipe ) : #NEWLINE# #INDENT# current_value = pipe . get ( key_str ) #NEWLINE# if ( current_value is None ) : #NEWLINE# #INDENT# current_value = 0.0 #NEWLINE# #UNINDENT# new_value = ( float ( current_value ) + field_val ) #NEWLINE# pipe . multi ( ) #NEWLINE# pipe . set ( key_str , new_value ) #NEWLINE# #UNINDENT# return conn . transaction ( incrbyfloat , key_str ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( tr_type . lower ( ) == 'delete' ) : #NEWLINE# #INDENT# def decrbyfloat( pipe ) : #NEWLINE# #INDENT# current_value = pipe . get ( key_str ) #NEWLINE# if ( current_value is None ) : #NEWLINE# #INDENT# current_value = 0.0 #NEWLINE# #UNINDENT# new_value = ( float ( current_value ) - field_val ) #NEWLINE# pipe . multi ( ) #NEWLINE# pipe . set ( key_str , new_value ) #NEWLINE# #UNINDENT# return conn . transaction ( tr_type , key_str ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Unknown transaction type' , tr_type )