def get_hash(path, form='sha1', chunk_size=4096):
    """Generate a hash digest string for a file."""
    try:
        hash_type = getattr(hashlib, form)
    except __HOLE__:
        raise ValueError('Invalid hash type: {0}'.format(form))
    with open(path, 'rb') as ifile:
        hash_obj = hash_type()
        # read the file in in chunks, not the entire file
        for chunk in iter(lambda: ifile.read(chunk_size), b''):
            hash_obj.update(chunk)
        return hash_obj.hexdigest()
dataset/ETHPy150Open saltstack/salt/salt/client/ssh/ssh_py_shim.py/get_hash