#NEWLINE# def get_value( self , section , option , default = None ) : #NEWLINE# #INDENT# '\n        :param default:\n            If not None, the given default value will be returned in case\n            the option did not exist\n        :return: a properly typed value, either int, float or string\n\n        :raise TypeError: in case the value could not be understood\n            Otherwise the exceptions known to the ConfigParser will be raised.' #NEWLINE# try : #NEWLINE# #INDENT# valuestr = self . get ( section , option ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# if ( default is not None ) : #NEWLINE# #INDENT# return default #NEWLINE# #UNINDENT# raise #NEWLINE# #UNINDENT# types = ( int , float ) #NEWLINE# for numtype in types : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# val = numtype ( valuestr ) #NEWLINE# if ( val != float ( valuestr ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# return val #NEWLINE# #UNINDENT# except ( ValueError , TypeError ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# vl = valuestr . lower ( ) #NEWLINE# if ( vl == 'false' ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( vl == 'true' ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# if ( not isinstance ( valuestr , string_types ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Invalid value type: only int, long, float and str are allowed' , valuestr ) #NEWLINE# #UNINDENT# return valuestr