#NEWLINE# def _get_column_type_heur( column , column_values ) : #NEWLINE# #INDENT# text_type_tuple = ( ColumnType . text , None ) #NEWLINE# if ( 'status' in column . title ) : #NEWLINE# #INDENT# if ( column_values . title == 'status' ) : #NEWLINE# #INDENT# return ( ColumnType . main_status , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( ColumnType . status , None ) #NEWLINE# #UNINDENT# #UNINDENT# column_type = None #NEWLINE# column_unit = column . unit #NEWLINE# if column_unit : #NEWLINE# #INDENT# explicit_unit_defined = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# explicit_unit_defined = False #NEWLINE# #UNINDENT# if ( int ( column . scale_factor ) != column . scale_factor ) : #NEWLINE# #INDENT# column_type = ColumnMeasureType ( 0 ) #NEWLINE# #UNINDENT# for value in column_values : #NEWLINE# #INDENT# if ( ( value is None ) or ( value == '' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# value_match = REGEX_MEASURE . match ( str ( value ) ) #NEWLINE# if ( value_match is None ) : #NEWLINE# #INDENT# return text_type_tuple #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not value_match . group ( GROUP_DEC_PART ) ) and ( ( not column_type ) or ( column_type . type == ColumnType . count ) ) ) : #NEWLINE# #INDENT# curr_column_unit = value_match . group ( GROUP_UNIT ) #NEWLINE# if ( column_unit and curr_column_unit and ( curr_column_unit != column_unit ) ) : #NEWLINE# #INDENT# if explicit_unit_defined : #NEWLINE# #INDENT# raise TypeError ( ( ( ( 'Values of different units in same column: ' + column_unit ) + ' and ' ) + curr_column_unit ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return text_type_tuple #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# column_type = ColumnType . count #NEWLINE# column_unit = curr_column_unit #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ( column_type and ( column_type . type == ColumnType . text ) ) ) : #NEWLINE# #INDENT# curr_column_unit = value_match . group ( GROUP_UNIT ) #NEWLINE# if curr_column_unit : #NEWLINE# #INDENT# if ( column_unit and ( curr_column_unit != column_unit ) ) : #NEWLINE# #INDENT# if explicit_unit_defined : #NEWLINE# #INDENT# raise TypeError ( ( ( ( 'Values of different units in same column: ' + column_unit ) + ' and ' ) + curr_column_unit ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return text_type_tuple #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# column_unit = curr_column_unit #NEWLINE# #UNINDENT# #UNINDENT# scaled_value = ( float ( Util . remove_unit ( str ( value ) ) ) * column . scale_factor ) #NEWLINE# if value_match . group ( GROUP_DEC_PART ) : #NEWLINE# #INDENT# dec_digits_before_scale = ( len ( value_match . group ( GROUP_DEC_PART ) ) - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dec_digits_before_scale = 0 #NEWLINE# #UNINDENT# max_number_of_dec_digits_after_scale = ( dec_digits_before_scale - math . ceil ( math . log10 ( column . scale_factor ) ) ) #NEWLINE# scaled_value = '{0:.{1}f}' . format ( scaled_value , max_number_of_dec_digits_after_scale ) #NEWLINE# scaled_value_match = REGEX_MEASURE . match ( scaled_value ) #NEWLINE# curr_dec_digits = _get_decimal_digits ( scaled_value_match , column . number_of_significant_digits ) #NEWLINE# try : #NEWLINE# #INDENT# max_dec_digits = column_type . max_decimal_digits #NEWLINE# #UNINDENT# except ( AttributeError or TypeError ) : #NEWLINE# #INDENT# max_dec_digits = 0 #NEWLINE# #UNINDENT# if ( curr_dec_digits > max_dec_digits ) : #NEWLINE# #INDENT# max_dec_digits = curr_dec_digits #NEWLINE# #UNINDENT# column_type = ColumnMeasureType ( max_dec_digits ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if column_type : #NEWLINE# #INDENT# return ( column_type , column_unit ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return text_type_tuple