'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
keep_going - don\'t stop at the first match, keep going
uncompress - Try to look inside compressed files.'

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

    self.flags = MAGIC_NONE
    if mime:
        self.flags |= MAGIC_MIME
    elif mime_encoding:
        self.flags |= MAGIC_MIME_ENCODING
    if keep_going:
        self.flags |= MAGIC_CONTINUE
    if uncompress:
        self.flags |= MAGIC_COMPRESS
    self.cookie = magic_open(self.flags)
    self.lock = threading.Lock()
    magic_load(self.cookie, magic_file)
