cpython: cfa3fe9d7b1f (original) (raw)

--- a/Doc/library/mimetypes.rst +++ b/Doc/library/mimetypes.rst @@ -1,4 +1,3 @@ - :mod:mimetypes --- Map filenames to MIME types ================================================ @@ -27,31 +26,31 @@ the module has not been initialized, the the information :func:init sets up. -.. function:: guess_type(filename[, strict]) +.. function:: guess_type(url, strict=True) .. index:: pair: MIME; headers

-.. function:: guess_all_extensions(type[, strict]) +.. function:: guess_all_extensions(type, strict=True) Guess the extensions for a file based on its MIME type, given by type. The return value is a list of strings giving all possible filename extensions, @@ -59,25 +58,25 @@ the information :func:init sets up. been associated with any particular data stream, but would be mapped to the MIME type type by :func:guess_type.

-.. function:: guess_extension(type[, strict]) +.. function:: guess_extension(type, strict=True) Guess the extension for a file based on its MIME type, given by type. The return value is a string giving a filename extension, including the leading dot ('.'). The extension is not guaranteed to have been associated with any

Some additional functions and data items are available for controlling the behavior of the module. -.. function:: init([files]) +.. function:: init(files=None) Initialize the internal data structures. If given, files must be a sequence of file names which should be used to augment the default type map. If omitted, @@ -92,26 +91,26 @@ behavior of the module. .. function:: read_mime_types(filename)

-.. function:: add_type(type, ext[, strict]) +.. function:: add_type(type, ext, strict=True)

.. data:: inited Flag indicating whether or not the global data structures have been initialized.

.. data:: knownfiles @@ -146,23 +145,6 @@ behavior of the module. Dictionary mapping filename extensions to non-standard, but commonly found MIME types. -The :class:MimeTypes class may be useful for applications which may want more -than one MIME-type database: - - -.. class:: MimeTypes([filenames]) -

An example usage of the module:: @@ -183,70 +165,96 @@ An example usage of the module:: MimeTypes Objects ----------------- -:class:MimeTypes instances provide an interface which is very like that of the +The :class:MimeTypes class may be useful for applications which may want more +than one MIME-type database; it provides an interface similar to the one of the :mod:mimetypes module. +.. class:: MimeTypes(filenames=(), strict=True) +

+ .. attribute:: MimeTypes.suffix_map Dictionary mapping suffixes to suffixes. This is used to allow recognition of encoded files for which the encoding and the type are indicated by the same extension. For example, the :file:.tgz extension is mapped to :file:.tar.gz to allow the encoding and type to be recognized separately. This is initially a

.. attribute:: MimeTypes.encodings_map Dictionary mapping filename extensions to encoding types. This is initially a

.. attribute:: MimeTypes.types_map

-.. attribute:: MimeTypes.common_types +.. attribute:: MimeTypes.types_map_inv

-.. method:: MimeTypes.guess_extension(type[, strict]) +.. method:: MimeTypes.guess_extension(type, strict=True) Similar to the :func:guess_extension function, using the tables stored as part of the object. -.. method:: MimeTypes.guess_all_extensions(type[, strict]) -

- -.. method:: MimeTypes.guess_type(url[, strict]) +.. method:: MimeTypes.guess_type(url, strict=True) Similar to the :func:guess_type function, using the tables stored as part of the object. -.. method:: MimeTypes.read(path) +.. method:: MimeTypes.guess_all_extensions(type, strict=True)

-.. method:: MimeTypes.readfp(file) +.. method:: MimeTypes.read(filename, strict=True) +

+ +.. method:: MimeTypes.readfp(fp, strict=True) +

-.. method:: MimeTypes.read_windows_registry() + +.. method:: MimeTypes.read_windows_registry(strict=True) Load MIME type information from the Windows registry. Availability: Windows.