{
    "content": [
        {
            "type": "text",
            "text": "# mimetypes (pydoc)\n\n**Summary:** mimetypes - Guess the MIME type of a file.\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **MODULE REFERENCE** (8 lines)\n- **DESCRIPTION** (2 lines) — 4 subsections\n  - guess_type (1 lines)\n  - guess_extension (12 lines)\n  - init (1 lines)\n  - read_mime_types (1 lines)\n- **CLASSES** (3 lines) — 1 subsections\n  - class MimeTypes (98 lines)\n- **FUNCTIONS** (1 lines) — 6 subsections\n  - add_type (11 lines)\n  - guess_all_extensions (12 lines)\n  - guess_extension (11 lines)\n  - guess_type (17 lines)\n  - init (1 lines)\n  - read_mime_types (1 lines)\n- **DATA** (8 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\nmimetypes - Guess the MIME type of a file.\n\n### MODULE REFERENCE\n\nhttps://docs.python.org/3.10/library/mimetypes.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n\n### DESCRIPTION\n\nThis module defines two useful functions:\n\n#### guess_type\n\n#### guess_extension\n\nIt also contains the following, for tuning the behavior:\n\nData:\n\nknownfiles -- list of files to parse\ninited -- flag set when init() has been called\nsuffixmap -- dictionary mapping suffixes to suffixes\nencodingsmap -- dictionary mapping suffixes to encodings\ntypesmap -- dictionary mapping suffixes to types\n\nFunctions:\n\n#### init\n\ndefault values are taken from the registry)\n\n#### read_mime_types\n\n### CLASSES\n\nbuiltins.object\nMimeTypes\n\n#### class MimeTypes\n\n|  MimeTypes(filenames=(), strict=True)\n|\n|  MIME-types datastore.\n|\n|  This datastore can handle information from mime.types-style files\n|  and supports basic determination of MIME type from a filename or\n|  URL, and can guess a reasonable extension given a MIME type.\n|\n|  Methods defined here:\n|\n|  init(self, filenames=(), strict=True)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  addtype(self, type, ext, strict=True)\n|      Add a mapping between a type and an extension.\n|\n|      When the extension is already known, the new\n|      type will replace the old one. When the type\n|      is already known the extension will be added\n|      to the list of known extensions.\n|\n|      If strict is true, information will be added to\n|      list of standard types, else to the list of non-standard\n|      types.\n|\n|  guessallextensions(self, type, strict=True)\n|      Guess the extensions for a file based on its MIME type.\n|\n|      Return value is a list of strings giving the possible filename\n|      extensions, including the leading dot ('.').  The extension is not\n|      guaranteed to have been associated with any particular data stream,\n|      but would be mapped to the MIME type `type' by guesstype().\n|\n|      Optional `strict' argument when false adds a bunch of commonly found,\n|      but non-standard types.\n|\n|  guessextension(self, type, strict=True)\n|      Guess the extension for a file based on its MIME type.\n|\n|      Return value is a string giving a filename extension,\n|      including the leading dot ('.').  The extension is not\n|      guaranteed to have been associated with any particular data\n|      stream, but would be mapped to the MIME type `type' by\n|      guesstype().  If no extension can be guessed for `type', None\n|      is returned.\n|\n|      Optional `strict' argument when false adds a bunch of commonly found,\n|      but non-standard types.\n|\n|  guesstype(self, url, strict=True)\n|      Guess the type of a file which is either a URL or a path-like object.\n|\n|      Return value is a tuple (type, encoding) where type is None if\n|      the type can't be guessed (no or unknown suffix) or a string\n|      of the form type/subtype, usable for a MIME Content-type\n|      header; and encoding is None for no encoding or the name of\n|      the program used to encode (e.g. compress or gzip).  The\n|      mappings are table driven.  Encoding suffixes are case\n|      sensitive; type suffixes are first tried case sensitive, then\n|      case insensitive.\n|\n|      The suffixes .tgz, .taz and .tz (case sensitive!) are all\n|      mapped to '.tar.gz'.  (This is table-driven too, using the\n|      dictionary suffixmap.)\n|\n|      Optional `strict' argument when False adds a bunch of commonly found,\n|      but non-standard types.\n|\n|  read(self, filename, strict=True)\n|      Read a single mime.types-format file, specified by pathname.\n|\n|      If strict is true, information will be added to\n|      list of standard types, else to the list of non-standard\n|      types.\n|\n|  readwindowsregistry(self, strict=True)\n|      Load the MIME types database from Windows registry.\n|\n|      If strict is true, information will be added to\n|      list of standard types, else to the list of non-standard\n|      types.\n|\n|  readfp(self, fp, strict=True)\n|      Read a single mime.types-format file.\n|\n|      If strict is true, information will be added to\n|      list of standard types, else to the list of non-standard\n|      types.\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### FUNCTIONS\n\n#### add_type\n\nAdd a mapping between a type and an extension.\n\nWhen the extension is already known, the new\ntype will replace the old one. When the type\nis already known the extension will be added\nto the list of known extensions.\n\nIf strict is true, information will be added to\nlist of standard types, else to the list of non-standard\ntypes.\n\n#### guess_all_extensions\n\nGuess the extensions for a file based on its MIME type.\n\nReturn value is a list of strings giving the possible filename\nextensions, including the leading dot ('.').  The extension is not\nguaranteed to have been associated with any particular data\nstream, but would be mapped to the MIME type `type' by\nguesstype().  If no extension can be guessed for `type', None\nis returned.\n\nOptional `strict' argument when false adds a bunch of commonly found,\nbut non-standard types.\n\n#### guess_extension\n\nGuess the extension for a file based on its MIME type.\n\nReturn value is a string giving a filename extension, including the\nleading dot ('.').  The extension is not guaranteed to have been\nassociated with any particular data stream, but would be mapped to the\nMIME type `type' by guesstype().  If no extension can be guessed for\n`type', None is returned.\n\nOptional `strict' argument when false adds a bunch of commonly found,\nbut non-standard types.\n\n#### guess_type\n\nGuess the type of a file based on its URL.\n\nReturn value is a tuple (type, encoding) where type is None if the\ntype can't be guessed (no or unknown suffix) or a string of the\nform type/subtype, usable for a MIME Content-type header; and\nencoding is None for no encoding or the name of the program used\nto encode (e.g. compress or gzip).  The mappings are table\ndriven.  Encoding suffixes are case sensitive; type suffixes are\nfirst tried case sensitive, then case insensitive.\n\nThe suffixes .tgz, .taz and .tz (case sensitive!) are all mapped\nto \".tar.gz\".  (This is table-driven too, using the dictionary\nsuffixmap).\n\nOptional `strict' argument when false adds a bunch of commonly found, but\nnon-standard types.\n\n#### init\n\n#### read_mime_types\n\n### DATA\n\nall = ['knownfiles', 'inited', 'MimeTypes', 'guesstype', 'guessa...\ncommontypes = {'.jpg': 'image/jpg', '.mid': 'audio/midi', '.midi': 'a...\nencodingsmap = {'.Z': 'compress', '.br': 'br', '.bz2': 'bzip2', '.gz'...\ninited = False\nknownfiles = ['/etc/mime.types', '/etc/httpd/mime.types', '/etc/httpd/...\nsuffixmap = {'.svgz': '.svg.gz', '.taz': '.tar.gz', '.tbz2': '.tar.bz...\ntypesmap = {'.3g2': 'audio/3gpp2', '.3gp': 'audio/3gpp', '.3gpp': 'au...\n\n### FILE\n\n/usr/lib/python3.10/mimetypes.py\n\n"
        }
    ],
    "structuredContent": {
        "command": "mimetypes",
        "section": "",
        "mode": "pydoc",
        "summary": "mimetypes - Guess the MIME type of a file.",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "MODULE REFERENCE",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": [
                    {
                        "name": "guess_type",
                        "lines": 1
                    },
                    {
                        "name": "guess_extension",
                        "lines": 12
                    },
                    {
                        "name": "init",
                        "lines": 1
                    },
                    {
                        "name": "read_mime_types",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "CLASSES",
                "lines": 3,
                "subsections": [
                    {
                        "name": "class MimeTypes",
                        "lines": 98
                    }
                ]
            },
            {
                "name": "FUNCTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "add_type",
                        "lines": 11
                    },
                    {
                        "name": "guess_all_extensions",
                        "lines": 12
                    },
                    {
                        "name": "guess_extension",
                        "lines": 11
                    },
                    {
                        "name": "guess_type",
                        "lines": 17
                    },
                    {
                        "name": "init",
                        "lines": 1
                    },
                    {
                        "name": "read_mime_types",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "DATA",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}