#NEWLINE# def sha1( fileOrPath , block_size = ( 2 ** 20 ) ) : #NEWLINE# #INDENT# 'Returns a SHA 1 checksum (as hex digest) of the given file (handle)' #NEWLINE# if ( type ( fileOrPath ) is str ) : #NEWLINE# #INDENT# fileOrPath = open ( fileOrPath , 'rb' ) #NEWLINE# #UNINDENT# sha1res = hashlib . sha1 ( ) #NEWLINE# while True : #NEWLINE# #INDENT# data = fileOrPath . read ( block_size ) #NEWLINE# if ( not data ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# sha1res . update ( data ) #NEWLINE# #UNINDENT# return sha1res . hexdigest ( )