def hash_from_file(filename):
    """
    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

    """

    if not os.path.exists(filename):
        raise IOError("Path not found")
    if not os.path.isfile(filename):
        raise IOError("File not found")
    if not os.access(filename, os.R_OK):
        raise IOError("File is not readable")

    result = ffi.new("char[]", binding.lib.FUZZY_MAX_RESULT)
    if binding.lib.fuzzy_hash_filename(filename.encode("utf-8"), result) != 0:
        raise InternalError("Function returned an unexpected error code")

    return ffi.string(result).decode("ascii")
def hash_from_file ( filename ) : if not os . path . exists ( filename ) : raise IOError ( "Path not found" ) if not os . path . isfile ( filename ) : raise IOError ( "File not found" ) if not os . access ( filename , os . R_OK ) : raise IOError ( "File is not readable" ) result = ffi . new ( "char[]" , binding . lib . FUZZY_MAX_RESULT ) if binding . lib . fuzzy_hash_filename ( filename . encode ( "utf-8" ) , result ) != 0 : raise InternalError ( "Function returned an unexpected error code" ) return ffi . string ( result ) . decode ( "ascii" )
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