#NEWLINE# def unique_hash( filepath , blocksize = ( 2 ** 20 ) ) : #NEWLINE# #INDENT# ' Small function to generate a hash to uniquely generate\n    a file. Inspired by MD5 version here:\n    http://stackoverflow.com/a/1131255/712997\n\n    Works with large files. \n    ' #NEWLINE# s = sha1 ( ) #NEWLINE# with open ( filepath , 'rb' ) as f : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# buf = f . read ( blocksize ) #NEWLINE# if ( not buf ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# s . update ( buf ) #NEWLINE# #UNINDENT# #UNINDENT# return s . hexdigest ( ) . upper ( )