def sha1sum_file(filename):
import hashlib<EOL>import io<EOL>sha1 = hashlib.sha1()<EOL>chunk_size = sha1.block_size * io.DEFAULT_BUFFER_SIZE<EOL>with open(filename, '<STR_LIT:rb>') as f:<EOL><INDENT>for chunk in iter(lambda: f.read(chunk_size), b'<STR_LIT>'):<EOL><INDENT>sha1.update(chunk)<EOL><DEDENT><DEDENT>return sha1.hexdigest()<EOL>
Return the secure hash digest with sha1 algorithm for a given file

>>> from timeside.core.tools.test_samples import samples
>>> wav_file = samples["C4_scale.wav"]
>>> print sha1sum_file(wav_file)
a598e78d0b5c90da54a77e34c083abdcd38d42ba