def MIME_TYPE(data, mime=True): try: return magic.from_buffer(data, mime=mime) except magic.MagicException: return "none/none"