#NEWLINE# def _parse_glance_iso8601_timestamp( timestamp ) : #NEWLINE# #INDENT# 'Parse a subset of iso8601 timestamps into datetime objects.' #NEWLINE# iso_formats = [ '%Y-%m-%dT%H:%M:%S.%f' , '%Y-%m-%dT%H:%M:%S' ] #NEWLINE# for iso_format in iso_formats : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return datetime . datetime . strptime ( timestamp , timestamp ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# raise ValueError ( ( _ ( '%(timestamp)s does not follow any of the signatures: %(ISO_FORMATS)s' ) % locals ( ) ) )