mimetypes.MimeTypes.encodings_map

MimeTypes.encodings_map Dictionary mapping filename extensions to encoding types. This is initially a copy of the global encodings_map defined in the module.

mimetypes.MimeTypes

class mimetypes.MimeTypes(filenames=(), strict=True) This class represents a MIME-types database. By default, it provides access to the same database as the rest of this module. The initial database is a copy of that provided by the module, and may be extended by loading additional mime.types-style files into the database using the read() or readfp() methods. The mapping dictionaries may also be cleared before loading additional data if the default data is not desired. The optional filenames

mimetypes.knownfiles

mimetypes.knownfiles List of type map file names commonly installed. These files are typically named mime.types and are installed in different locations by different packages.

mimetypes.inited

mimetypes.inited Flag indicating whether or not the global data structures have been initialized. This is set to True by init().

mimetypes.init()

mimetypes.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, the file names to use are taken from knownfiles; on Windows, the current registry settings are loaded. Each file named in files or knownfiles takes precedence over those named before it. Calling init() repeatedly is allowed. Specifying an empty list for files will prevent the system defaults from being applied:

mimetypes.guess_type()

mimetypes.guess_type(url, strict=True) Guess the type of a file based on its filename or URL, given by url. The return value is a tuple (type, encoding) where type is None if the type can’t be guessed (missing or unknown suffix) or a string of the form 'type/subtype', usable for a MIME content-type header. encoding is None for no encoding or the name of the program used to encode (e.g. compress or gzip). The encoding is suitable for use as a Content-Encoding header, not as a Content-Transfer

mimetypes.guess_extension()

mimetypes.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 particular data stream, but would be mapped to the MIME type type by guess_type(). If no extension can be guessed for type, None is returned. The optional strict argument has the same meaning as with the guess_type() function

mimetypes.guess_all_extensions()

mimetypes.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, including the leading dot ('.'). The extensions are not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type type by guess_type(). The optional strict argument has the same meaning as with the guess_type() function.

mimetypes.encodings_map

mimetypes.encodings_map Dictionary mapping filename extensions to encoding types.

mimetypes.common_types

mimetypes.common_types Dictionary mapping filename extensions to non-standard, but commonly found MIME types.