#NEWLINE# def is_sync_needed( key , local_file_path ) : #NEWLINE# #INDENT# "\n    Checks if the local file is identical to the S3 key by using the file's md5 hash.\n\n    :param key:                         The S3 key object.\n    :param local_file_path:             (str), path to download the key to\n    " #NEWLINE# sync_needed = True #NEWLINE# if ( os . path . exists ( local_file_path ) and key . exists ( ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# key_etag = key . etag #NEWLINE# if ( not key_etag ) : #NEWLINE# #INDENT# key_etag = key . bucket . lookup ( key . name ) . etag #NEWLINE# #UNINDENT# local_md5 = ( ( '"' + hashlib . md5 ( open ( local_file_path , 'rb' ) . read ( ) ) . hexdigest ( ) ) + '"' ) #NEWLINE# sync_needed = ( key_etag != local_md5 ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# logger . exception ( 'Cannot compare local file {0} against remote file {1}. s3concurrent will process it anyway.' . format ( local_file_path , key . name ) ) #NEWLINE# #UNINDENT# #UNINDENT# return sync_needed