{
    "content": [
        {
            "type": "text",
            "text": "# magic (pydoc)\n\n**Summary:** magic - magic is a wrapper around the libmagic file identification library.\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **DESCRIPTION** (13 lines)\n- **PACKAGE CONTENTS** (3 lines)\n- **CLASSES** (5 lines) — 2 subsections\n  - class Magic (39 lines)\n  - class MagicException (69 lines)\n- **FUNCTIONS** (2 lines) — 15 subsections\n  - byref (4 lines)\n  - coerce_filename (6 lines)\n  - errorcheck_negative_one (1 lines)\n  - errorcheck_null (1 lines)\n  - from_buffer (7 lines)\n  - from_descriptor (8 lines)\n  - from_file (8 lines)\n  - magic_buffer (1 lines)\n  - magic_descriptor (1 lines)\n  - magic_file (1 lines)\n  - magic_getparam (1 lines)\n  - magic_load (1 lines)\n  - magic_setparam (1 lines)\n  - maybe_decode (5 lines)\n  - version (1 lines)\n- **DATA** (72 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\nmagic - magic is a wrapper around the libmagic file identification library.\n\n### DESCRIPTION\n\nSee README for more information.\n\nUsage:\n\n>>> import magic\n>>> magic.fromfile(\"testdata/test.pdf\")\n'PDF document, version 1.2'\n>>> magic.fromfile(\"testdata/test.pdf\", mime=True)\n'application/pdf'\n>>> magic.frombuffer(open(\"testdata/test.pdf\").read(1024))\n'PDF document, version 1.2'\n>>>\n\n### PACKAGE CONTENTS\n\ncompat\nloader\n\n### CLASSES\n\nbuiltins.Exception(builtins.BaseException)\nMagicException\nbuiltins.object\nMagic\n\n#### class Magic\n\n|  Magic(mime=False, magicfile=None, mimeencoding=False, keepgoing=False, uncompress=False, raw=False, extension=False)\n|\n|  Magic is a wrapper around the libmagic C library.\n|\n|  Methods defined here:\n|\n|  del(self)\n|\n|  init(self, mime=False, magicfile=None, mimeencoding=False, keepgoing=False, uncompress=False, raw=False, extension=False)\n|      Create a new libmagic wrapper.\n|\n|      mime - if True, mimetypes are returned instead of textual descriptions\n|      mimeencoding - if True, codec is returned\n|      magicfile - use a mime database other than the system default\n|      keepgoing - don't stop at the first match, keep going\n|      uncompress - Try to look inside compressed files.\n|      raw - Do not try to decode \"non-printable\" chars.\n|      extension - Print a slash-separated list of valid extensions for the file type found.\n|\n|  frombuffer(self, buf)\n|      Identify the contents of `buf`\n|\n|  fromdescriptor(self, fd)\n|\n|  fromfile(self, filename)\n|\n|  getparam(self, param)\n|\n|  setparam(self, param, val)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n\n#### class MagicException\n\n|  MagicException(message)\n|\n|  Method resolution order:\n|      MagicException\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  init(self, message)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n\n### FUNCTIONS\n\nPOINTER(...)\n\n#### byref\n\nbyref(C instance[, offset=0]) -> byref-object\nReturn a pointer lookalike to a C instance, only usable\nas function argument\n\n#### coerce_filename\n\ndetectfromcontent = (*args, kwargs)\n\ndetectfromfilename = (*args, kwargs)\n\ndetectfromfobj = (*args, kwargs)\n\n#### errorcheck_negative_one\n\n#### errorcheck_null\n\n#### from_buffer\n\nAccepts a binary string and returns the detected filetype.  Return\nvalue is the mimetype if mime=True, otherwise a human readable\nname.\n\n>>> magic.frombuffer(open(\"testdata/test.pdf\").read(1024))\n'PDF document, version 1.2'\n\n#### from_descriptor\n\nAccepts a file descriptor and returns the detected filetype.  Return\nvalue is the mimetype if mime=True, otherwise a human readable\nname.\n\n>>> f = open(\"testdata/test.pdf\")\n>>> magic.fromdescriptor(f.fileno())\n'PDF document, version 1.2'\n\n#### from_file\n\n\"\nAccepts a filename and returns the detected filetype.  Return\nvalue is the mimetype if mime=True, otherwise a human readable\nname.\n\n>>> magic.fromfile(\"testdata/test.pdf\", mime=True)\n'application/pdf'\n\n#### magic_buffer\n\n#### magic_descriptor\n\n#### magic_file\n\n#### magic_getparam\n\n#### magic_load\n\n#### magic_setparam\n\n#### maybe_decode\n\n# return str on python3.  Don't want to unconditionally\n# decode because that results in unicode on python2\n\nopen = (*args, kwargs)\n\n#### version\n\n### DATA\n\nAPPLE = 2048\nCHECK = 64\nCOMPRESS = 4\nCONTINUE = 32\nDEBUG = 1\nDEFAULTMODE = 0\nDEVICES = 8\nERROR = 512\nMAGICAPPLE = 2048\nMAGICCHECK = 64\nMAGICCOMPRESS = 4\nMAGICCONTINUE = 32\nMAGICDEBUG = 1\nMAGICDEVICES = 8\nMAGICERROR = 512\nMAGICEXTENSION = 16777216\nMAGICMIME = 16\nMAGICMIMEENCODING = 1024\nMAGICMIMETYPE = 16\nMAGICNONE = 0\nMAGICNOCHECKAPPTYPE = 32768\nMAGICNOCHECKASCII = 131072\nMAGICNOCHECKBUILTIN = 4173824\nMAGICNOCHECKCDF = 262144\nMAGICNOCHECKCOMPRESS = 4096\nMAGICNOCHECKELF = 65536\nMAGICNOCHECKENCODING = 2097152\nMAGICNOCHECKFORTRAN = 524288\nMAGICNOCHECKSOFT = 16384\nMAGICNOCHECKTAR = 8192\nMAGICNOCHECKTEXT = 131072\nMAGICNOCHECKTOKENS = 1048576\nMAGICNOCHECKTROFF = 262144\nMAGICPARAMBYTESMAX = 6\nMAGICPARAMELFNOTESMAX = 4\nMAGICPARAMELFPHNUMMAX = 2\nMAGICPARAMELFSHNUMMAX = 3\nMAGICPARAMINDIRMAX = 0\nMAGICPARAMNAMEMAX = 1\nMAGICPARAMREGEXMAX = 5\nMAGICPRESERVEATIME = 128\nMAGICRAW = 256\nMAGICSYMLINK = 2\nMIME = 1040\nMIMEENCODING = 1024\nMIMETYPE = 16\nNONE = 0\nNOCHECKAPPTYPE = 32768\nNOCHECKBUILTIN = 4173824\nNOCHECKCDF = 262144\nNOCHECKCOMPRESS = 4096\nNOCHECKELF = 65536\nNOCHECKENCODING = 2097152\nNOCHECKSOFT = 16384\nNOCHECKTAR = 8192\nNOCHECKTEXT = 131072\nNOCHECKTOKENS = 1048576\nPRESERVEATIME = 128\nRAW = 256\nRTLDGLOBAL = 256\nRTLDLOCAL = 0\nSYMLINK = 2\nlibmagic = <CDLL 'libmagic.so.1', handle 563e2ed69cb0>\nmagiccheck = <FuncPtr object>\nmagicclose = <FuncPtr object>\nmagiccompile = <FuncPtr object>\nmagicerrno = <FuncPtr object>\nmagicerror = <FuncPtr object>\nmagicopen = <FuncPtr object>\nmagicsetflags = <FuncPtr object>\nmagicversion = <FuncPtr object>\n\n### FILE\n\n/usr/lib/python3/dist-packages/magic/init.py\n\n"
        }
    ],
    "structuredContent": {
        "command": "magic",
        "section": "",
        "mode": "pydoc",
        "summary": "magic - magic is a wrapper around the libmagic file identification library.",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "PACKAGE CONTENTS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "CLASSES",
                "lines": 5,
                "subsections": [
                    {
                        "name": "class Magic",
                        "lines": 39
                    },
                    {
                        "name": "class MagicException",
                        "lines": 69
                    }
                ]
            },
            {
                "name": "FUNCTIONS",
                "lines": 2,
                "subsections": [
                    {
                        "name": "byref",
                        "lines": 4
                    },
                    {
                        "name": "coerce_filename",
                        "lines": 6
                    },
                    {
                        "name": "errorcheck_negative_one",
                        "lines": 1
                    },
                    {
                        "name": "errorcheck_null",
                        "lines": 1
                    },
                    {
                        "name": "from_buffer",
                        "lines": 7
                    },
                    {
                        "name": "from_descriptor",
                        "lines": 8
                    },
                    {
                        "name": "from_file",
                        "lines": 8
                    },
                    {
                        "name": "magic_buffer",
                        "lines": 1
                    },
                    {
                        "name": "magic_descriptor",
                        "lines": 1
                    },
                    {
                        "name": "magic_file",
                        "lines": 1
                    },
                    {
                        "name": "magic_getparam",
                        "lines": 1
                    },
                    {
                        "name": "magic_load",
                        "lines": 1
                    },
                    {
                        "name": "magic_setparam",
                        "lines": 1
                    },
                    {
                        "name": "maybe_decode",
                        "lines": 5
                    },
                    {
                        "name": "version",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "DATA",
                "lines": 72,
                "subsections": []
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}