code: def sha1sum(filename):
      
      sha1 = hashlib.sha1()
      with open(filename, 'rb') as f:
          for chunk in iter(lambda: f.read(128 * sha1.block_size), b''):
              sha1.update(chunk)
      return sha1.hexdigest()
docs: Calculates sha1 hash of a file