| mimetypes | index /usr/lib/python2.2/mimetypes.py |
Guess the MIME type of a file.
This module defines two useful functions:
guess_type(url, strict=1) -- guess the MIME type and encoding of a URL.
guess_extension(type, strict=1) -- guess the extension for a given MIME type.
It also contains the following, for tuning the behavior:
Data:
knownfiles -- list of files to parse
inited -- flag set when init() has been called
suffix_map -- dictionary mapping suffixes to suffixes
encodings_map -- dictionary mapping suffixes to encodings
types_map -- dictionary mapping suffixes to types
Functions:
init([files]) -- parse a list of files, default knownfiles
read_mime_types(file) -- parse one file, return a dictionary or None
| Modules | ||||||
| ||||||
| Classes | ||||||||||
| ||||||||||
| Functions | ||
| ||
| Data | ||
| __all__ = ['guess_type', 'guess_extension', 'read_mime_types', 'init'] __file__ = '/usr/lib/python2.2/mimetypes.pyc' __name__ = 'mimetypes' common_types = {'.jpg': 'image/jpg', '.mid': 'audio/midi', '.midi': 'audio/midi', '.pct': 'image/pict', '.pic': 'image/pict', '.pict': 'image/pict', '.rtf': 'application/rtf', '.xul': 'text/xul'} encodings_map = {'.Z': 'compress', '.gz': 'gzip'} inited = 0 knownfiles = ['/usr/local/etc/httpd/conf/mime.types', '/usr/local/lib/netscape/mime.types', '/usr/local/etc/httpd/conf/mime.types', '/usr/local/etc/mime.types'] suffix_map = {'.taz': '.tar.gz', '.tgz': '.tar.gz', '.tz': '.tar.gz'} types_map = {'.a': 'application/octet-stream', '.ai': 'application/postscript', '.aif': 'audio/x-aiff', '.aifc': 'audio/x-aiff', '.aiff': 'audio/x-aiff', '.au': 'audio/basic', '.avi': 'video/x-msvideo', '.bat': 'text/plain', '.bcpio': 'application/x-bcpio', '.bin': 'application/octet-stream', ...} | ||