#NEWLINE# def to_python( self , obj ) : #NEWLINE# #INDENT# 'Converts strings in a data structure to Python types\n\n        It converts datetime-ish things to Python datetimes.\n\n        Override if you want something different.\n\n        :arg obj: Python datastructure\n\n        :returns: Python datastructure with strings converted to\n            Python types\n\n        .. Note::\n\n           This does the conversion in-place!\n\n        ' #NEWLINE# if isinstance ( obj , string_types ) : #NEWLINE# #INDENT# if ( len ( obj ) == 26 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return datetime . strptime ( obj , '%Y-%m-%dT%H:%M:%S.%f' ) #NEWLINE# #UNINDENT# except ( TypeError , ValueError ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( obj ) == 19 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return datetime . strptime ( obj , '%Y-%m-%dT%H:%M:%S' ) #NEWLINE# #UNINDENT# except ( TypeError , ValueError ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( obj ) == 10 ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return datetime . strptime ( obj , '%Y-%m-%d' ) #NEWLINE# #UNINDENT# except ( TypeError , ValueError ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( obj , dict ) : #NEWLINE# #INDENT# for ( key , val ) in obj . items ( ) : #NEWLINE# #INDENT# obj [ key ] = self . to_python ( val ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( obj , list ) : #NEWLINE# #INDENT# return [ self . to_python ( item ) for item in obj ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return obj