#NEWLINE# def _postprocess( valuestr ) : #NEWLINE# #INDENT# '\n    Takes value as str, returns str, int, float, date, datetime, or time\n    ' #NEWLINE# intpattern = re . compile ( '^\\-?\\d+$' ) #NEWLINE# floatpattern = re . compile ( '^\\-?\\d+\\.\\d+(E[+-]?\\d\\d+)?$' ) #NEWLINE# datedtpattern = '%Y-%m-%d' #NEWLINE# datedttimepattern = '%Y-%m-%dT%H:%M:%SZ' #NEWLINE# timedtpattern = '%H:%M:%S.%f' #NEWLINE# timepattern = re . compile ( '^\\d{2}:\\d{2}:\\d{2}(\\.\\d{6})?' ) #NEWLINE# if ( valuestr . startswith ( '"' ) and valuestr . endswith ( '"' ) ) : #NEWLINE# #INDENT# return valuestr [ 1 : ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if re . match ( intpattern , valuestr ) : #NEWLINE# #INDENT# return int ( valuestr ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if re . match ( floatpattern , valuestr ) : #NEWLINE# #INDENT# return float ( valuestr ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# return datetime . datetime . strptime ( valuestr , datedtpattern ) . date ( ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return datetime . datetime . strptime ( valuestr , datedttimepattern ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# mat = re . match ( timepattern , valuestr ) #NEWLINE# if mat : #NEWLINE# #INDENT# test = mat . group ( 0 ) #NEWLINE# try : #NEWLINE# #INDENT# return datetime . datetime . strptime ( test , timedtpattern ) . time ( ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# logging . info ( ( ( "The value %s couldn't be parsed as " % valuestr ) + 'int, float, date, time, datetime. Returning it as string.' ) ) #NEWLINE# return valuestr