'Create a new libmagic wrapper.
mime - if True, mimetypes are returned instead of textual descriptions
mime_encoding - if True, codec is returned
magic_file - use a mime database other than the system default'

def __init__(self, mime=False, magic_file=None, mime_encoding=False):

    flags = MAGIC_NONE
    if mime:
        flags |= MAGIC_MIME
    elif mime_encoding:
        flags |= MAGIC_MIME_ENCODING
    self.cookie = magic_open(flags)
    magic_load(self.cookie, magic_file)
