rest25/library/mimetypes.rst => rest262/library/mimetypes.rst
34
35   *encoding* is ``None`` for no encoding or the name of the program used to encode
36   (e.g. :program:`compress` or :program:`gzip`). The encoding is suitable for use
37   as a :mailheader:`Content-Encoding` header, *not* as a
38   :mailheader:`Content-Transfer-Encoding` header. The mappings are table driven.
39   Encoding suffixes are case sensitive; type suffixes are first tried case
40   sensitively, then case insensitively.
41
n42-   Optional *strict* is a flag specifying whether the list of known MIME types is
n42+   Optional *strict* is a flag specifying whether the list of known MIME types
43-   limited to only the official types `registered with IANA <http://www.isi.edu/in-
43+   is limited to only the official types `registered with IANA
44-   notes/iana/assignments/media-types>`_ are recognized.  When *strict* is true
44+   <http://www.iana.org/assignments/media-types/>`_ are recognized.
45-   (the default), only the IANA types are supported; when *strict* is false, some
45+   When *strict* is true (the default), only the IANA types are supported; when
46-   additional non-standard but commonly used MIME types are also recognized.
46+   *strict* is false, some additional non-standard but commonly used MIME types
47+   are also recognized.
47
48
49.. function:: guess_all_extensions(type[, strict])
50
51   Guess the extensions for a file based on its MIME type, given by *type*. The
52   return value is a list of strings giving all possible filename extensions,
53   including the leading dot (``'.'``).  The extensions are not guaranteed to have
54   been associated with any particular data stream, but would be mapped to the MIME
90
91
92.. function:: add_type(type, ext[, strict])
93
94   Add a mapping from the mimetype *type* to the extension *ext*. When the
95   extension is already known, the new type will replace the old one. When the type
96   is already known the extension will be added to the list of known extensions.
97
n98-   When *strict* is the mapping will added to the official MIME types, otherwise to
n99+   When *strict* is True (the default), the mapping will added to the official MIME
99-   the non-standard ones.
100+   types, otherwise to the non-standard ones.
100
101
102.. data:: inited
103
104   Flag indicating whether or not the global data structures have been initialized.
105   This is set to true by :func:`init`.
106
107
173
174MimeTypes Objects
175-----------------
176
177:class:`MimeTypes` instances provide an interface which is very like that of the
178:mod:`mimetypes` module.
179
180
n181-.. data:: suffix_map
n182+.. attribute:: MimeTypes.suffix_map
182
183   Dictionary mapping suffixes to suffixes.  This is used to allow recognition of
184   encoded files for which the encoding and the type are indicated by the same
185   extension.  For example, the :file:`.tgz` extension is mapped to :file:`.tar.gz`
186   to allow the encoding and type to be recognized separately.  This is initially a
187   copy of the global ``suffix_map`` defined in the module.
188
189
n190-.. data:: encodings_map
n191+.. attribute:: MimeTypes.encodings_map
191
192   Dictionary mapping filename extensions to encoding types.  This is initially a
193   copy of the global ``encodings_map`` defined in the module.
194
195
n196-.. data:: types_map
n197+.. attribute:: MimeTypes.types_map
197
198   Dictionary mapping filename extensions to MIME types.  This is initially a copy
199   of the global ``types_map`` defined in the module.
200
201
n202-.. data:: common_types
n203+.. attribute:: MimeTypes.common_types
203
204   Dictionary mapping filename extensions to non-standard, but commonly found MIME
205   types.  This is initially a copy of the global ``common_types`` defined in the
206   module.
207
208
n209-.. method:: XXX Class.guess_extension(type[, strict])
n210+.. method:: MimeTypes.guess_extension(type[, strict])
210
211   Similar to the :func:`guess_extension` function, using the tables stored as part
212   of the object.
213
214
n215-.. method:: XXX Class.guess_type(url[, strict])
n216+.. method:: MimeTypes.guess_type(url[, strict])
216
217   Similar to the :func:`guess_type` function, using the tables stored as part of
218   the object.
219
220
n221-.. method:: XXX Class.read(path)
n222+.. method:: MimeTypes.read(path)
222
223   Load MIME information from a file named *path*.  This uses :meth:`readfp` to
224   parse the file.
225
226
t227-.. method:: XXX Class.readfp(file)
t228+.. method:: MimeTypes.readfp(file)
228
229   Load MIME type information from an open file.  The file must have the format of
230   the standard :file:`mime.types` files.
231
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op