grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026î £ f-Qã@s±dZddlZddlZddlZddlZyddlZWnek r`dZYnXddddddgZ d d d d d ddddg Z da da Gdd„dƒZ ddd„Zddd„Zddd„Zddd„Zddd„Zdd„Zdd„Zeƒedkr­ddlZdZdd d!„Zy5ejejd"d…d#d$d%d&gƒ\ZZWn5ejk r¼Zzed"eƒWYddZ[XnXd"ZdZxWeD]O\Z Z!e d0krõedƒqÐe d1kr dZqÐe d2krÐd"ZqÐqÐWx‡eD]|Z"erhee"eƒZ#e#s[e$d-e"ƒq¦e$e#ƒq*ee"eƒ\Z#Z%e#s“e$d-e"ƒq*e$d.e#d/e%ƒq*WndS)3aìGuess the MIME type of a file. This module defines two useful functions: guess_type(url, strict=True) -- guess the MIME type and encoding of a URL. guess_extension(type, strict=True) -- 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 (on Windows, the default values are taken from the registry) read_mime_types(file) -- parse one file, return a dictionary or None éNÚ guess_typeÚguess_extensionÚguess_all_extensionsÚadd_typeÚread_mime_typesÚinitz/etc/mime.typesz/etc/httpd/mime.typesz/etc/httpd/conf/mime.typesz/etc/apache/mime.typesz/etc/apache2/mime.typesz$/usr/local/etc/httpd/conf/mime.typesz"/usr/local/lib/netscape/mime.typesz/usr/local/etc/mime.typesFc@s‘eZdZdZfddd„Zddd„Zddd„Zdd d „Zdd d „Zdd d„Z ddd„Z ddd„Z dS)Ú MimeTypeszçMIME-types datastore. This datastore can handle information from mime.types-style files and supports basic determination of MIME type from a filename or URL, and can guess a reasonable extension given a MIME type. TcCsÑtstƒntjƒ|_tjƒ|_iif|_iif|_x-tjƒD]\}}|j||dƒqYWx-t jƒD]\}}|j||dƒq‰Wx|D]}|j ||ƒq³WdS)NTF) ÚinitedrÚ encodings_mapÚcopyÚ suffix_mapÚ types_mapÚ types_map_invÚitemsrÚ common_typesÚread)ÚselfÚ filenamesÚstrictÚextÚtypeÚname©rú./opt/alt/python34/lib64/python3.4/mimetypes.pyÚ__init__@s  zMimeTypes.__init__cCsJ||j||<|j|j|gƒ}||krF|j|ƒndS)a‰Add a mapping between a type and an extension. When the extension is already known, the new type will replace the old one. When the type is already known the extension will be added to the list of known extensions. If strict is true, information will be added to list of standard types, else to the list of non-standard types. N)r rÚ setdefaultÚappend)rrrrZextsrrrrNs  zMimeTypes.add_typec Csïtjj|ƒ\}}|dkr²|jdƒ}|dkrCd S|jdd|ƒ}|dkrw|d|…}n|d|…}d|ksŸd|kr¨d}n|dfStj|ƒ\}}x3||jkrütj||j|ƒ\}}qÊW||jkr1|j|} tj|ƒ\}}nd} |jd } || kr^| || fS|j ƒ| kr„| |j ƒ| fS|r”d| fS|jd } || kr»| || fS|j ƒ| krá| |j ƒ| fSd| fSdS) a:Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no encoding or the name of the program used to encode (e.g. compress or gzip). The mappings are table driven. Encoding suffixes are case sensitive; type suffixes are first tried case sensitive, then case insensitive. The suffixes .tgz, .taz and .tz (case sensitive!) are all mapped to '.tar.gz'. (This is table-driven too, using the dictionary suffix_map.) Optional `strict' argument when False adds a bunch of commonly found, but non-standard types. Údataú,rNú;ú=ú/z text/plainTF)NN) ÚurllibÚparseZ splittypeÚfindÚ posixpathÚsplitextr r r Úlower) rÚurlrÚschemeZcommaZsemirÚbaserÚencodingr rrrr_s@     $      zMimeTypes.guess_typecCsr|jƒ}|jdj|gƒ}|snx@|jdj|gƒD]"}||krE|j|ƒqEqEWn|S)aÓGuess the extensions for a file based on its MIME type. Return value is a list of strings giving the possible filename extensions, 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(). Optional `strict' argument when false adds a bunch of commonly found, but non-standard types. TF)r'rÚgetr)rrrÚ extensionsrrrrr�s   zMimeTypes.guess_all_extensionscCs$|j||ƒ}|sdS|dS)a Guess the extension for a file based on its MIME type. 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. Optional `strict' argument when false adds a bunch of commonly found, but non-standard types. Nr)r)rrrr-rrrr°s zMimeTypes.guess_extensionc Cs/t|ddƒ�}|j||ƒWdQXdS)z× Read a single mime.types-format file, specified by pathname. If strict is true, information will be added to list of standard types, else to the list of non-standard types. r+zutf-8N)ÚopenÚreadfp)rÚfilenamerÚfprrrrÂszMimeTypes.readc Cs¾x·|jƒ}|sPn|jƒ}x?tt|ƒƒD]+}||ddkr8||d…=Pq8q8W|ssqn|d|dd…}}x%|D]}|j|d||ƒq•WqWdS)zÀ Read a single mime.types-format file. If strict is true, information will be added to list of standard types, else to the list of non-standard types. rú#NéÚ.)ÚreadlineÚsplitÚrangeÚlenr) rr1rÚlineZwordsÚirÚsuffixesZsuffrrrr/Ís    zMimeTypes.readfpcCsÛts dSdd„}tjtjdƒ�ª}x ||ƒD]’}yttj||ƒ�\}|jdƒsnw;ntj|dƒ\}}|tjkr›w;n|j|||ƒWdQXWq;tk rÌw;Yq;Xq;WWdQXdS)zÎ Load the MIME types database from Windows registry. If strict is true, information will be added to list of standard types, else to the list of non-standard types. Nc ss[d}xNytj||ƒ}Wntk r4PYnXd|krI|Vn|d7}q WdS)NrÚr3)Ú_winregZEnumKeyÚEnvironmentError)Zmimedbr:ZctyperrrÚ enum_typesñs  z3MimeTypes.read_windows_registry..enum_typesÚr4z Content Type)r=ÚOpenKeyZHKEY_CLASSES_ROOTÚ startswithZ QueryValueExZREG_SZrr>)rrr?ZhkcrZ subkeynameZsubkeyZmimetypeZdatatyperrrÚread_windows_registryäs   zMimeTypes.read_windows_registryN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrr/rCrrrrr8s > rTcCs&tdkrtƒntj||ƒS)aþGuess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no encoding or the name of the program used to encode (e.g. compress or gzip). The mappings are table driven. Encoding suffixes are case sensitive; type suffixes are first tried case sensitive, then case insensitive. The suffixes .tgz, .taz and .tz (case sensitive!) are all mapped to ".tar.gz". (This is table-driven too, using the dictionary suffix_map). Optional `strict' argument when false adds a bunch of commonly found, but non-standard types. N)Ú_dbrr)r(rrrrr s  cCs&tdkrtƒntj||ƒS)aýGuess the extensions for a file based on its MIME type. Return value is a list of strings giving the possible filename extensions, 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. Optional `strict' argument when false adds a bunch of commonly found, but non-standard types. N)rHrr)rrrrrr$s  cCs&tdkrtƒntj||ƒS)aãGuess the extension for a file based on its MIME type. 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. Optional `strict' argument when false adds a bunch of commonly found, but non-standard types. N)rHrr)rrrrrr5s  cCs)tdkrtƒntj|||ƒS)aiAdd a mapping between a type and an extension. When the extension is already known, the new type will replace the old one. When the type is already known the extension will be added to the list of known extensions. If strict is true, information will be added to list of standard types, else to the list of non-standard types. N)rHrr)rrrrrrrEs  cCs datƒ}|dkr7tr.|jƒnt}nx0|D](}tjj|ƒr>|j|ƒq>q>W|j a |j a |j da |j da |a dS)NTF)r rr=rCÚ knownfilesÚosÚpathÚisfilerr r r rrH)ÚfilesÚdbÚfilerrrrVs         cCs^yt|ƒ}Wntk r(dSYnX|�)tƒ}|j|dƒ|jdSWdQXdS)NT)r.ÚOSErrorrr/r )rOÚfrNrrrrjs   cCs idd6dd6dd6dd6dd6d d 6aid d 6d d6dd6dd6ai~dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6dd#6d$d%6dd&6d'd(6d)d(6d*d+6d,d-6d.d/6dd06d1d26d1d36d4d56d6d76dd86d9d:6dd;6d<d=6d>d?6dd@6dAdB6dCdD6dCdE6dFdG6dHdI6dJdK6dJdL6dJdM6dNdO6ddP6dQdR6dSdT6dUdV6dUdW6dXdY6dZd[6d6d\6d6d]6d^d_6d`da6dbdc6ddde6dddf6dgdh6dSdi6dSdj6dSdk6dSdl6dmdn6d)do6d6dp6ddq6ddr6dsdt6dudv6dwdx6dydz6d{d|6dud}6d~d6dd€6d�d‚6dƒd„6d…d†6d…d‡6dˆd‰6d…dŠ6d…d‹6ddŒ6d…d�6dŽd�6d�d‘6d�d’6d`d“6d”d•6d–d—6d˜d™6dšd›6dœd�6dždŸ6d d¡6d¢d£6d¢d¤6d¥d¦6d§d¨6dd©6ddª6d«d¬6d­d®6d¯d°6d±d²6d³d´6dždµ6d¶d·6d¸d¹6dºd»6d¼d½6d¼d¾6d¿dÀ6d¿dÁ6dždÂ6dÃdÄ6ddÅ6dÆdÇ6dÈdÉ6dÊdË6d1dÌ6dšdÍ6dÎdÏ6dÐdÑ6dÒdÓ6dÐdÓ6dÔdÕ6dšdÖ6d×dØ6dšdÙ6dÚdÛ6dÜdÝ6aidÞdM6dßdà6dßdá6dâdã6dâdä6dâdå6dædç6dèdé6adS)êNz.svg.gzz.svgzz.tar.gzz.tgzz.tazz.tzz.tar.bz2z.tbz2z.tar.xzz.txzZgzipz.gzÚcompressz.ZZbzip2z.bz2Zxzz.xzzapplication/octet-streamz.azapplication/postscriptz.aiz audio/x-aiffz.aifz.aifcz.aiffz audio/basicz.auzvideo/x-msvideoz.aviz text/plainz.batzapplication/x-bcpioz.bcpioz.binzimage/x-ms-bmpz.bmpz.czapplication/x-cdfz.cdfzapplication/x-netcdfzapplication/x-cpioz.cpiozapplication/x-cshz.cshztext/cssz.cssz.dllzapplication/mswordz.docz.dotzapplication/x-dviz.dvizmessage/rfc822z.emlz.epsz text/x-setextz.etxz.exez image/gifz.gifzapplication/x-gtarz.gtarz.hzapplication/x-hdfz.hdfz text/htmlz.htmz.htmlzimage/vnd.microsoft.iconz.icoz image/iefz.iefz image/jpegz.jpez.jpegz.jpgzapplication/javascriptz.jsz.kshzapplication/x-latexz.latexz video/mpegz.m1vzapplication/vnd.apple.mpegurlz.m3uz.m3u8zapplication/x-troff-manz.manzapplication/x-troff-mez.mez.mhtz.mhtmlzapplication/x-mifz.mifzvideo/quicktimez.movzvideo/x-sgi-moviez.moviez audio/mpegz.mp2z.mp3z video/mp4z.mp4z.mpaz.mpez.mpegz.mpgzapplication/x-troff-msz.msz.ncz.nwsz.oz.objzapplication/odaz.odazapplication/x-pkcs12z.p12zapplication/pkcs7-mimez.p7czimage/x-portable-bitmapz.pbmzapplication/pdfz.pdfz.pfxzimage/x-portable-graymapz.pgmz.plz image/pngz.pngzimage/x-portable-anymapz.pnmzapplication/vnd.ms-powerpointz.potz.ppazimage/x-portable-pixmapz.ppmz.ppsz.pptz.psz.pwzz text/x-pythonz.pyzapplication/x-python-codez.pycz.pyoz.qtzaudio/x-pn-realaudioz.razapplication/x-pn-realaudioz.ramzimage/x-cmu-rasterz.raszapplication/xmlz.rdfz image/x-rgbz.rgbzapplication/x-troffz.roffz text/richtextz.rtxz text/x-sgmlz.sgmz.sgmlzapplication/x-shz.shzapplication/x-sharz.sharz.sndz.sozapplication/x-wais-sourcez.srczapplication/x-sv4cpioz.sv4cpiozapplication/x-sv4crcz.sv4crcz image/svg+xmlz.svgzapplication/x-shockwave-flashz.swfz.tzapplication/x-tarz.tarzapplication/x-tclz.tclzapplication/x-texz.texzapplication/x-texinfoz.texiz.texinfoz image/tiffz.tifz.tiffz.trztext/tab-separated-valuesz.tsvz.txtzapplication/x-ustarz.ustarz text/x-vcardz.vcfz audio/x-wavz.wavz.wizz.wsdlzimage/x-xbitmapz.xbmzapplication/vnd.ms-excelz.xlbzapplication/excelz.xlsztext/xmlz.xmlz.xpdlzimage/x-xpixmapz.xpmz.xslzimage/x-xwindowdumpz.xwdzapplication/zipz.zipz image/jpgz audio/midiz.midz.midiz image/pictz.pctz.picz.pictzapplication/rtfz.rtfztext/xulz.xul)r r r rrrrrÚ_default_mime_typesus(   rSÚ__main__a4Usage: mimetypes.py [options] type Options: --help / -h -- print this message and exit --lenient / -l -- additionally search of some common, but non-standard types. --extension / -e -- guess extension instead of type More than one type argument may be given. r@cCs.ttƒ|rt|ƒntj|ƒdS)N)ÚprintÚUSAGEÚsysÚexit)ÚcodeÚmsgrrrÚusage5s  r[r3ZhleÚhelpZlenientÚ extensionú-hú--helpú-lú --lenientú-eú --extensionz I don't know anything about typeztype:z encoding:)r^r_)r`ra)rbrc)&rGrJrWr%Z urllib.parser"Úwinregr=Ú ImportErrorÚ__all__rIr rHrrrrrrrrSrDZgetoptrVr[ÚargvZoptsÚargsÚerrorrZrr]ZoptÚargZgtypeZguessrUr+rrrrÚst        Õ ®