def hash_from_file(filename):
if not os.path.exists(filename):<EOL><INDENT>raise IOError("<STR_LIT>")<EOL><DEDENT>if not os.path.isfile(filename):<EOL><INDENT>raise IOError("<STR_LIT>")<EOL><DEDENT>if not os.access(filename, os.R_OK):<EOL><INDENT>raise IOError("<STR_LIT>")<EOL><DEDENT>result = ffi.new("<STR_LIT>", binding.lib.FUZZY_MAX_RESULT)<EOL>if binding.lib.fuzzy_hash_filename(filename.encode("<STR_LIT:utf-8>"), result) != <NUM_LIT:0>:<EOL><INDENT>raise InternalError("<STR_LIT>")<EOL><DEDENT>return ffi.string(result).decode("<STR_LIT:ascii>")<EOL>
Compute the fuzzy hash of a file.

Opens, reads, and hashes the contents of the file 'filename'

:param String|Bytes filename: The name of the file to be hashed
:return: The fuzzy hash of the file
:rtype: String
:raises IOError: If Python is unable to read the file
:raises InternalError: If lib returns an internal error