![]() That provided by the module, and may be extended by loading additional The same database as the rest of this module. This class represents a MIME-types database. MimeTypes ( filenames = (), strict = True ) ¶ Than one MIME-type database it provides an interface similar to the one of the The MimeTypes class may be useful for applications which may want more types_map 'application/x-tar-gz' MimeTypes Objects ¶ common_types ¶ĭictionary mapping filename extensions to non-standard, but commonly found MIME types_map ¶ĭictionary mapping filename extensions to MIME types. encodings_map ¶ĭictionary mapping filename extensions to encoding types. To allow the encoding and type to be recognized separately. This is used to allow recognition ofĮncoded files for which the encoding and the type are indicated by the sameĮxtension. Mime.types and are installed in different locations by differentĭictionary mapping suffixes to suffixes. List of type map file names commonly installed. inited ¶įlag indicating whether or not the global data structures have been initialized. Official MIME types, otherwise to the non-standard ones. When strict is True (the default), the mapping will be added to the Is already known the extension will be added to the list of known extensions. When theĮxtension is already known, the new type will replace the old one. add_type ( type, ext, strict = True ) ¶Īdd a mapping from the MIME type type to the extension ext. If the file filenameĭoes not exist or cannot be read, None is returned. ( '.'), to strings of the form 'type/subtype'. Returned as a dictionary mapping filename extensions, including the leading dot Load the type map given in the file filename, if it exists. This is a stable operation and will produce the same resultsĬhanged in version 3.2: Previously, Windows registry settings were ignored. If files is None the internal data structure is completely rebuilt to its Specifying an empty list for files will prevent the system defaults fromīeing applied: only the well-known values will be present from a built-in list. Knownfiles takes precedence over those named before it. The file names to use are taken from knownfiles on Windows, theĬurrent registry settings are loaded. Of file names which should be used to augment the default type map. Some additional functions and data items are available for controlling theīehavior of the module. The optional strict argument has the same meaning as with the guess_type() function. ![]() If no extension can be guessed for type, None is Particular data stream, but would be mapped to the MIME type type by The extension is not guaranteed to have been associated with any Return value is a string giving a filename extension, including the leading dot ![]() Guess the extension for a file based on its MIME type, given by type. guess_extension ( type, strict = True ) ¶ The extensions are not guaranteed to haveīeen associated with any particular data stream, but would be mapped to the MIME ![]() Return value is a list of strings giving all possible filename extensions, Guess the extensions for a file based on its MIME type, given by type. guess_all_extensions ( type, strict = True ) ¶ Strict is False, some additional non-standard but commonly used MIME typesĬhanged in version 3.8: Added support for url being a path-like object. When strict is True (the default), only the IANA types are supported when Is limited to only the official types registered with IANA. The optional strict argument is a flag specifying whether the list of known MIME types The mappings are table driven.Įncoding suffixes are case sensitive type suffixes are first tried case The encoding is suitable for useĬontent-Transfer-Encoding header. 'type/subtype', usable for a MIME content-type header.Įncoding is None for no encoding or the name of the program used to encode Type can’t be guessed (missing or unknown suffix) or a string of the form The return value is a tuple (type, encoding) where type is None if the URL can be a string or a path-like object. Guess the type of a file based on its filename, path or URL, given by url. The module has not been initialized, they will call init() if they rely on The functions described below provide the primary interface for this module. Theįunctions are the normal interface to this module, but some applications may be The module provides one class and a number of convenience functions. To MIME type and from MIME type to filename extension encodings are not The mimetypes module converts between a filename or URL and the MIME typeĪssociated with the filename extension. Mimetypes - Map filenames to MIME types ¶
0 Comments
Leave a Reply. |