#NEWLINE# def bind_value( self , value ) : #NEWLINE# #INDENT# 'Given a value, infer type and display options.' #NEWLINE# self . _data_type = self . data_type_for_value ( value ) #NEWLINE# if ( value is None ) : #NEWLINE# #INDENT# self . set_value_explicit ( '' , self . TYPE_NULL ) #NEWLINE# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . _data_type == self . TYPE_STRING ) : #NEWLINE# #INDENT# percentage_search = self . RE_PATTERNS [ 'percentage' ] . match ( value ) #NEWLINE# if ( percentage_search and ( value . strip ( ) != '%' ) ) : #NEWLINE# #INDENT# value = ( float ( value . replace ( '%' , '' ) ) / 100.0 ) #NEWLINE# self . set_value_explicit ( value , self . TYPE_NUMERIC ) #NEWLINE# self . _set_number_format ( NumberFormat . FORMAT_PERCENTAGE ) #NEWLINE# return True #NEWLINE# #UNINDENT# time_search = self . RE_PATTERNS [ 'time' ] . match ( value ) #NEWLINE# if time_search : #NEWLINE# #INDENT# sep_count = value . count ( ':' ) #NEWLINE# if ( sep_count == 1 ) : #NEWLINE# #INDENT# ( hours , minutes ) = [ int ( bit ) for bit in value . split ( ':' ) ] #NEWLINE# seconds = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( sep_count == 2 ) : #NEWLINE# #INDENT# ( hours , minutes , seconds ) = [ int ( bit ) for bit in value . split ( ':' ) ] #NEWLINE# #UNINDENT# #UNINDENT# days = ( ( ( hours / 24.0 ) + ( minutes / 1440.0 ) ) + ( seconds / 86400.0 ) ) #NEWLINE# self . set_value_explicit ( days , self . TYPE_NUMERIC ) #NEWLINE# self . _set_number_format ( NumberFormat . FORMAT_DATE_TIME3 ) #NEWLINE# return True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( self . _data_type == self . TYPE_NUMERIC ) : #NEWLINE# #INDENT# if ( isinstance ( value , datetime . date ) and ( not isinstance ( value , datetime . datetime ) ) ) : #NEWLINE# #INDENT# value = datetime . datetime . combine ( value , datetime . time ( ) ) #NEWLINE# #UNINDENT# if isinstance ( value , datetime . datetime ) : #NEWLINE# #INDENT# value = SharedDate ( ) . datetime_to_julian ( date = value ) #NEWLINE# self . set_value_explicit ( value , self . TYPE_NUMERIC ) #NEWLINE# self . _set_number_format ( NumberFormat . FORMAT_DATE_YYYYMMDD2 ) #NEWLINE# return True #NEWLINE# #UNINDENT# #UNINDENT# self . set_value_explicit ( value , self . _data_type )