Kaydet (Commit) 04b9403e authored tarafından Anthony Baxter's avatar Anthony Baxter

Fix for failure of test_urllib2 breaking test_mimetypes (SF bug 1464978)

will backport.
üst e94e3b44
...@@ -315,162 +315,171 @@ def read_mime_types(file): ...@@ -315,162 +315,171 @@ def read_mime_types(file):
return db.types_map[True] return db.types_map[True]
suffix_map = { def _default_mime_types():
'.tgz': '.tar.gz', global suffix_map
'.taz': '.tar.gz', global encodings_map
'.tz': '.tar.gz', global types_map
} global common_types
encodings_map = { suffix_map = {
'.gz': 'gzip', '.tgz': '.tar.gz',
'.Z': 'compress', '.taz': '.tar.gz',
} '.tz': '.tar.gz',
}
# Before adding new types, make sure they are either registered with IANA, at
# http://www.isi.edu/in-notes/iana/assignments/media-types encodings_map = {
# or extensions, i.e. using the x- prefix '.gz': 'gzip',
'.Z': 'compress',
# If you add to these, please keep them sorted! }
types_map = {
'.a' : 'application/octet-stream', # Before adding new types, make sure they are either registered with IANA,
'.ai' : 'application/postscript', # at http://www.isi.edu/in-notes/iana/assignments/media-types
'.aif' : 'audio/x-aiff', # or extensions, i.e. using the x- prefix
'.aifc' : 'audio/x-aiff',
'.aiff' : 'audio/x-aiff', # If you add to these, please keep them sorted!
'.au' : 'audio/basic', types_map = {
'.avi' : 'video/x-msvideo', '.a' : 'application/octet-stream',
'.bat' : 'text/plain', '.ai' : 'application/postscript',
'.bcpio' : 'application/x-bcpio', '.aif' : 'audio/x-aiff',
'.bin' : 'application/octet-stream', '.aifc' : 'audio/x-aiff',
'.bmp' : 'image/x-ms-bmp', '.aiff' : 'audio/x-aiff',
'.c' : 'text/plain', '.au' : 'audio/basic',
# Duplicates :( '.avi' : 'video/x-msvideo',
'.cdf' : 'application/x-cdf', '.bat' : 'text/plain',
'.cdf' : 'application/x-netcdf', '.bcpio' : 'application/x-bcpio',
'.cpio' : 'application/x-cpio', '.bin' : 'application/octet-stream',
'.csh' : 'application/x-csh', '.bmp' : 'image/x-ms-bmp',
'.css' : 'text/css', '.c' : 'text/plain',
'.dll' : 'application/octet-stream', # Duplicates :(
'.doc' : 'application/msword', '.cdf' : 'application/x-cdf',
'.dot' : 'application/msword', '.cdf' : 'application/x-netcdf',
'.dvi' : 'application/x-dvi', '.cpio' : 'application/x-cpio',
'.eml' : 'message/rfc822', '.csh' : 'application/x-csh',
'.eps' : 'application/postscript', '.css' : 'text/css',
'.etx' : 'text/x-setext', '.dll' : 'application/octet-stream',
'.exe' : 'application/octet-stream', '.doc' : 'application/msword',
'.gif' : 'image/gif', '.dot' : 'application/msword',
'.gtar' : 'application/x-gtar', '.dvi' : 'application/x-dvi',
'.h' : 'text/plain', '.eml' : 'message/rfc822',
'.hdf' : 'application/x-hdf', '.eps' : 'application/postscript',
'.htm' : 'text/html', '.etx' : 'text/x-setext',
'.html' : 'text/html', '.exe' : 'application/octet-stream',
'.ief' : 'image/ief', '.gif' : 'image/gif',
'.jpe' : 'image/jpeg', '.gtar' : 'application/x-gtar',
'.jpeg' : 'image/jpeg', '.h' : 'text/plain',
'.jpg' : 'image/jpeg', '.hdf' : 'application/x-hdf',
'.js' : 'application/x-javascript', '.htm' : 'text/html',
'.ksh' : 'text/plain', '.html' : 'text/html',
'.latex' : 'application/x-latex', '.ief' : 'image/ief',
'.m1v' : 'video/mpeg', '.jpe' : 'image/jpeg',
'.man' : 'application/x-troff-man', '.jpeg' : 'image/jpeg',
'.me' : 'application/x-troff-me', '.jpg' : 'image/jpeg',
'.mht' : 'message/rfc822', '.js' : 'application/x-javascript',
'.mhtml' : 'message/rfc822', '.ksh' : 'text/plain',
'.mif' : 'application/x-mif', '.latex' : 'application/x-latex',
'.mov' : 'video/quicktime', '.m1v' : 'video/mpeg',
'.movie' : 'video/x-sgi-movie', '.man' : 'application/x-troff-man',
'.mp2' : 'audio/mpeg', '.me' : 'application/x-troff-me',
'.mp3' : 'audio/mpeg', '.mht' : 'message/rfc822',
'.mpa' : 'video/mpeg', '.mhtml' : 'message/rfc822',
'.mpe' : 'video/mpeg', '.mif' : 'application/x-mif',
'.mpeg' : 'video/mpeg', '.mov' : 'video/quicktime',
'.mpg' : 'video/mpeg', '.movie' : 'video/x-sgi-movie',
'.ms' : 'application/x-troff-ms', '.mp2' : 'audio/mpeg',
'.nc' : 'application/x-netcdf', '.mp3' : 'audio/mpeg',
'.nws' : 'message/rfc822', '.mpa' : 'video/mpeg',
'.o' : 'application/octet-stream', '.mpe' : 'video/mpeg',
'.obj' : 'application/octet-stream', '.mpeg' : 'video/mpeg',
'.oda' : 'application/oda', '.mpg' : 'video/mpeg',
'.p12' : 'application/x-pkcs12', '.ms' : 'application/x-troff-ms',
'.p7c' : 'application/pkcs7-mime', '.nc' : 'application/x-netcdf',
'.pbm' : 'image/x-portable-bitmap', '.nws' : 'message/rfc822',
'.pdf' : 'application/pdf', '.o' : 'application/octet-stream',
'.pfx' : 'application/x-pkcs12', '.obj' : 'application/octet-stream',
'.pgm' : 'image/x-portable-graymap', '.oda' : 'application/oda',
'.pl' : 'text/plain', '.p12' : 'application/x-pkcs12',
'.png' : 'image/png', '.p7c' : 'application/pkcs7-mime',
'.pnm' : 'image/x-portable-anymap', '.pbm' : 'image/x-portable-bitmap',
'.pot' : 'application/vnd.ms-powerpoint', '.pdf' : 'application/pdf',
'.ppa' : 'application/vnd.ms-powerpoint', '.pfx' : 'application/x-pkcs12',
'.ppm' : 'image/x-portable-pixmap', '.pgm' : 'image/x-portable-graymap',
'.pps' : 'application/vnd.ms-powerpoint', '.pl' : 'text/plain',
'.ppt' : 'application/vnd.ms-powerpoint', '.png' : 'image/png',
'.ps' : 'application/postscript', '.pnm' : 'image/x-portable-anymap',
'.pwz' : 'application/vnd.ms-powerpoint', '.pot' : 'application/vnd.ms-powerpoint',
'.py' : 'text/x-python', '.ppa' : 'application/vnd.ms-powerpoint',
'.pyc' : 'application/x-python-code', '.ppm' : 'image/x-portable-pixmap',
'.pyo' : 'application/x-python-code', '.pps' : 'application/vnd.ms-powerpoint',
'.qt' : 'video/quicktime', '.ppt' : 'application/vnd.ms-powerpoint',
'.ra' : 'audio/x-pn-realaudio', '.ps' : 'application/postscript',
'.ram' : 'application/x-pn-realaudio', '.pwz' : 'application/vnd.ms-powerpoint',
'.ras' : 'image/x-cmu-raster', '.py' : 'text/x-python',
'.rdf' : 'application/xml', '.pyc' : 'application/x-python-code',
'.rgb' : 'image/x-rgb', '.pyo' : 'application/x-python-code',
'.roff' : 'application/x-troff', '.qt' : 'video/quicktime',
'.rtx' : 'text/richtext', '.ra' : 'audio/x-pn-realaudio',
'.sgm' : 'text/x-sgml', '.ram' : 'application/x-pn-realaudio',
'.sgml' : 'text/x-sgml', '.ras' : 'image/x-cmu-raster',
'.sh' : 'application/x-sh', '.rdf' : 'application/xml',
'.shar' : 'application/x-shar', '.rgb' : 'image/x-rgb',
'.snd' : 'audio/basic', '.roff' : 'application/x-troff',
'.so' : 'application/octet-stream', '.rtx' : 'text/richtext',
'.src' : 'application/x-wais-source', '.sgm' : 'text/x-sgml',
'.sv4cpio': 'application/x-sv4cpio', '.sgml' : 'text/x-sgml',
'.sv4crc' : 'application/x-sv4crc', '.sh' : 'application/x-sh',
'.swf' : 'application/x-shockwave-flash', '.shar' : 'application/x-shar',
'.t' : 'application/x-troff', '.snd' : 'audio/basic',
'.tar' : 'application/x-tar', '.so' : 'application/octet-stream',
'.tcl' : 'application/x-tcl', '.src' : 'application/x-wais-source',
'.tex' : 'application/x-tex', '.sv4cpio': 'application/x-sv4cpio',
'.texi' : 'application/x-texinfo', '.sv4crc' : 'application/x-sv4crc',
'.texinfo': 'application/x-texinfo', '.swf' : 'application/x-shockwave-flash',
'.tif' : 'image/tiff', '.t' : 'application/x-troff',
'.tiff' : 'image/tiff', '.tar' : 'application/x-tar',
'.tr' : 'application/x-troff', '.tcl' : 'application/x-tcl',
'.tsv' : 'text/tab-separated-values', '.tex' : 'application/x-tex',
'.txt' : 'text/plain', '.texi' : 'application/x-texinfo',
'.ustar' : 'application/x-ustar', '.texinfo': 'application/x-texinfo',
'.vcf' : 'text/x-vcard', '.tif' : 'image/tiff',
'.wav' : 'audio/x-wav', '.tiff' : 'image/tiff',
'.wiz' : 'application/msword', '.tr' : 'application/x-troff',
'.wsdl' : 'application/xml', '.tsv' : 'text/tab-separated-values',
'.xbm' : 'image/x-xbitmap', '.txt' : 'text/plain',
'.xlb' : 'application/vnd.ms-excel', '.ustar' : 'application/x-ustar',
# Duplicates :( '.vcf' : 'text/x-vcard',
'.xls' : 'application/excel', '.wav' : 'audio/x-wav',
'.xls' : 'application/vnd.ms-excel', '.wiz' : 'application/msword',
'.xml' : 'text/xml', '.wsdl' : 'application/xml',
'.xpdl' : 'application/xml', '.xbm' : 'image/x-xbitmap',
'.xpm' : 'image/x-xpixmap', '.xlb' : 'application/vnd.ms-excel',
'.xsl' : 'application/xml', # Duplicates :(
'.xwd' : 'image/x-xwindowdump', '.xls' : 'application/excel',
'.zip' : 'application/zip', '.xls' : 'application/vnd.ms-excel',
} '.xml' : 'text/xml',
'.xpdl' : 'application/xml',
# These are non-standard types, commonly found in the wild. They will only '.xpm' : 'image/x-xpixmap',
# match if strict=0 flag is given to the API methods. '.xsl' : 'application/xml',
'.xwd' : 'image/x-xwindowdump',
# Please sort these too '.zip' : 'application/zip',
common_types = { }
'.jpg' : 'image/jpg',
'.mid' : 'audio/midi', # These are non-standard types, commonly found in the wild. They will
'.midi': 'audio/midi', # only match if strict=0 flag is given to the API methods.
'.pct' : 'image/pict',
'.pic' : 'image/pict', # Please sort these too
'.pict': 'image/pict', common_types = {
'.rtf' : 'application/rtf', '.jpg' : 'image/jpg',
'.xul' : 'text/xul' '.mid' : 'audio/midi',
} '.midi': 'audio/midi',
'.pct' : 'image/pict',
'.pic' : 'image/pict',
'.pict': 'image/pict',
'.rtf' : 'application/rtf',
'.xul' : 'text/xul'
}
_default_mime_types()
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -8,6 +8,7 @@ from test import test_support ...@@ -8,6 +8,7 @@ from test import test_support
# Tell it we don't know about external files: # Tell it we don't know about external files:
mimetypes.knownfiles = [] mimetypes.knownfiles = []
mimetypes.inited = False mimetypes.inited = False
mimetypes._default_mime_types()
class MimeTypesTestCase(unittest.TestCase): class MimeTypesTestCase(unittest.TestCase):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment