grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026o ®û|j Xã@südZddlZddlZddlZddlZzddlmZWn ey%dZYnwzddl Z Wn ey7dZ Ynwgd¢Z gd¢Z da daGdd„dƒZdd d „Zdd d „Zddd„Zddd„Zddd„Zdd„Zdd„Zeƒdd„Zedkr|eƒdSdS)aì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)Ú _mimetypes_read_windows_registry) Ú knownfilesÚinitedÚ MimeTypesÚ guess_typeÚguess_all_extensionsÚguess_extensionÚadd_typeÚinitÚread_mime_typesÚ suffix_mapÚ encodings_mapÚ types_mapÚ common_types) z/etc/mime.typesz/etc/httpd/mime.typesz/etc/httpd/conf/mime.typesz/etc/apache/mime.typesz/etc/apache2/mime.typesú$/usr/local/etc/httpd/conf/mime.typesz"/usr/local/lib/netscape/mime.typesrz/usr/local/etc/mime.typesFc@sleZdZdZddd„Zddd„Zddd „Zdd d „Zdd d „Zddd„Z ddd„Z ddd„Z e dd„ƒZ dS)rzç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ƒt ¡|_t ¡|_iif|_iif|_t   ¡D] \}}|  ||d¡qt   ¡D] \}}|  ||d¡q-|D]}|  ||¡q;dS©NTF)rr Ú_encodings_map_defaultÚcopyr Ú_suffix_map_defaultr rÚ types_map_invÚ_types_map_defaultÚitemsr Ú_common_types_defaultÚread)ÚselfÚ filenamesÚstrictÚextÚtypeÚnamerrú0/opt/alt/python310/lib64/python3.10/mimetypes.pyÚ__init__Hs    ÿzMimeTypes.__init__cCs:||j||<|j| |g¡}||vr| |¡dSdS)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)rrÚ setdefaultÚappend)rrrrZextsrrr!r Vs  ÿzMimeTypes.add_typec CsNt |¡}tj |¡\}}|dkrB| d¡}|dkrdS| dd|¡}|dkr.|d|…}n|d|…}d|vsd }|dfSt |¡\}}| ¡} |j vrgt ||j | ¡\}}| ¡} |j vsR||j vry|j |} t |¡\}}nd} | ¡}|j d } || vrŽ| || fS|r”d| fS|j d } || vr£| || fSd| fS) aUGuess the type of a file which is either a URL or a path-like object. 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ú,r)NNú;Nú=ú/ú text/plainTF) ÚosÚfspathÚurllibÚparseZ _splittypeÚfindÚ posixpathÚsplitextÚlowerr r r) rÚurlrZschemeZcommaZsemirÚbaserZ ext_lowerÚencodingrrrr!rgs>   ÿ      zMimeTypes.guess_typecCsP| ¡}t|jd |g¡ƒ}|s&|jd |g¡D] }||vr%| |¡q|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)r2ÚlistrÚgetr$)rrrÚ extensionsrrrr!r¤s  €zMimeTypes.guess_all_extensionscCs| ||¡}|s dS|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)rrrr8rrr!r·s zMimeTypes.guess_extensioncCs>t|dd��}| ||¡WdƒdS1swYdS)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. úutf-8©r5N)ÚopenÚreadfp)rÚfilenamerÚfprrr!rÉs"ÿzMimeTypes.readc Cs„ | ¡}|s dS| ¡}tt|ƒƒD]}||ddkr$||d…=nq|s(q|d|dd…}}|D] }| |d||¡q5q)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 ) rr>rÚlineZwordsÚirÚsuffixesZsuffrrr!r<Ôs  þózMimeTypes.readfpcsHtstsdSˆj}|r‡fdd„}trt|ƒdStr"ˆ |¡dSdS)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. Ncsˆ ||d¡S)NT)r )rr©rrr!Úùsz1MimeTypes.read_windows_registry..)rÚ_winregr Ú_read_windows_registry)rrr rrIr!Úread_windows_registryës   ÿzMimeTypes.read_windows_registryc CsÞdd„}t tjd¡�Z}||ƒD]L}zAt ||¡�1}| d¡s( WdƒWqt |d¡\}}|tjkr> WdƒWq|||ƒWdƒn1sMwYWqty\YqwWdƒdS1shwYdS)NcssF�d} zt ||¡}Wn tyYdSwd|vr|V|d7}q)NrTúr?)rKZEnumKeyÚOSError)ZmimedbrGZctyperrr!Ú enum_typess€ ÿøz4MimeTypes._read_windows_registry..enum_typesÚrAz Content Type)rKÚOpenKeyZHKEY_CLASSES_ROOTÚ startswithZ QueryValueExZREG_SZrO)Úclsr rPZhkcrZ subkeynameZsubkeyZmimetypeZdatatyperrr!rLs,  ýÿ ø ÷€ ÿô"ÿz MimeTypes._read_windows_registryN)rT©T)Ú__name__Ú __module__Ú __qualname__Ú__doc__r"r rrrrr<rMÚ classmethodrLrrrr!r@s    =   rTcCótdurtƒt ||¡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)Ú_dbr r)r3rrrr!rs rcCr[)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)r\r r©rrrrr!r6s  rcCr[)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)r\r rr]rrr!rGs  rcCstdurtƒt |||¡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)r\r r )rrrrrr!r Ws r cCsŠda|dus tdurtƒ}| ¡|durt}n tt|ƒ}nt}|D] }tj |¡r0|  |¡q#|j a |j a |j da |j da |adSr)rr\rrMrr6r+ÚpathÚisfilerr r rr)ÚfilesÚdbÚfilerrr!r hs"  €  r cCsjzt|dd�}Wn tyYdSw|�tƒ}| |d¡|jdWdƒS1s.wYdS)Nr9r:T)r;rOrr<r)rbÚfrarrr!r „s ÿ $ýr c Cs°dddddddœaadddd d d œaaid d “dd “dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd “d!d"“d#d$“id%d&“d'd&“d(d&“d)d*“d+d*“d,d-“d.d-“d/d0“d1d0“d2d0“d3d0“d4d0“d5d6“d7d8“d9d:“d;d<“d=d>“¥id?d@“dAdB“dCdD“dEdF“dGdH“dIdJ“dKdJ“dLdM“dNdM“dOdP“dQdR“dSdR“dTdU“dVdW“dXdY“dZd[“d\d]“¥id^d_“d`da“dbdc“ddde“dfde“dgdh“didh“djdh“dkdl“dmdn“dodp“dqdr“dsdt“dudv“dwdv“dxdv“dydv“¥idzd{“d|d}“d~d}“dd€“d�d€“d‚dƒ“d„dƒ“d…dƒ“d†dƒ“d‡dˆ“d‰dˆ“dŠd‹“dŒd‹“d�dŽ“d�d�“d‘d�“d’d�“¥id“d”“d•d–“d—d˜“d™dš“d›dœ“d�dž“dŸdž“d dž“d¡d¢“d£d¤“d¥d¦“d§d¨“d©dª“d«dª“d¬d­“d®d¯“d—d°“¥id±d²“d³d´“dµd¶“d·d¸“d¹dº“d»d¼“d½d¾“d¿dÀ“dÁd“dÃd“dÄd“dÅd“dÆdÇ“dÈdÉ“dÊdË“dÌdË“dÍdΓ¥idÏdΓdÐdΓdÑdΓdÒdΓdÓdΓdÔdÕ“dÖdדdØdÙ“dÚdÛ“dÜdÝ“dÞdÝ“dßdà“dádâ“dãdä“dådæ“dçdæ“dèdæ“¥dædædédédêdëdìd휥aadîdïdïdðdñdñdñdòdóœaadS)ôNz.svg.gzz.tar.gzz.tar.bz2z.tar.xz)z.svgzz.tgzz.tazz.tzz.tbz2z.txzZgzipÚcompressZbzip2ZxzÚbr)z.gzz.Zz.bz2z.xzz.brz.jszapplication/javascriptz.mjsz.jsonzapplication/jsonz .webmanifestzapplication/manifest+jsonz.doczapplication/mswordz.dotz.wizz.binzapplication/octet-streamz.az.dllz.exez.oz.objz.soz.odazapplication/odaz.pdfzapplication/pdfz.p7czapplication/pkcs7-mimez.pszapplication/postscriptz.aiz.epsz.m3uzapplication/vnd.apple.mpegurlz.m3u8z.xlszapplication/vnd.ms-excelz.xlbz.pptzapplication/vnd.ms-powerpointz.potz.ppaz.ppsz.pwzz.wasmzapplication/wasmz.bcpiozapplication/x-bcpioz.cpiozapplication/x-cpioz.cshzapplication/x-cshz.dvizapplication/x-dviz.gtarzapplication/x-gtarz.hdfzapplication/x-hdfz.h5zapplication/x-hdf5z.latexzapplication/x-latexz.mifzapplication/x-mifz.cdfzapplication/x-netcdfz.ncz.p12zapplication/x-pkcs12z.pfxz.ramzapplication/x-pn-realaudioz.pyczapplication/x-python-codez.pyoz.shzapplication/x-shz.sharzapplication/x-sharz.swfzapplication/x-shockwave-flashz.sv4cpiozapplication/x-sv4cpioz.sv4crczapplication/x-sv4crcz.tarzapplication/x-tarz.tclzapplication/x-tclz.texzapplication/x-texz.texizapplication/x-texinfoz.texinfoz.roffzapplication/x-troffz.tz.trz.manzapplication/x-troff-manz.mezapplication/x-troff-mez.mszapplication/x-troff-msz.ustarzapplication/x-ustarz.srczapplication/x-wais-sourcez.xslzapplication/xmlz.rdfz.wsdlz.xpdlz.zipzapplication/zipz.3gpz audio/3gppz.3gppz.3g2z audio/3gpp2z.3gpp2z.aacz audio/aacz.adtsz.loasz.assz.auz audio/basicz.sndz.mp3z audio/mpegz.mp2z.opusz audio/opusz.aifz audio/x-aiffz.aifcz.aiffz.razaudio/x-pn-realaudioz.wavz audio/x-wavz.bmpz image/bmpz.gifz image/gifz.iefz image/iefú.jpgz image/jpegz.jpez.jpegz.heicz image/heicz.heifz image/heifz.pngz image/pngz.svgz image/svg+xmlz.tiffz image/tiffz.tifz.icozimage/vnd.microsoft.iconz.raszimage/x-cmu-rasterzimage/x-ms-bmpz.pnmzimage/x-portable-anymapz.pbmzimage/x-portable-bitmapz.pgmzimage/x-portable-graymapz.ppmzimage/x-portable-pixmapz.rgbz image/x-rgbz.xbmzimage/x-xbitmapz.xpmzimage/x-xpixmapz.xwdzimage/x-xwindowdumpz.emlzmessage/rfc822z.mhtz.mhtmlz.nwsz.cssztext/cssz.csvztext/csvz.htmlz text/htmlz.htmz.txtr*z.batz.cz.hz.kshz.plz.rtxz text/richtextz.tsvztext/tab-separated-valuesz.pyz text/x-pythonz.etxz text/x-setextz.sgmz text/x-sgmlz.sgmlz.vcfz text/x-vcardz.xmlztext/xmlz.mp4z video/mp4z.mpegz video/mpegz.m1vz.mpazvideo/quicktimez video/webmzvideo/x-msvideozvideo/x-sgi-movie)z.mpez.mpgz.movz.qtz.webmz.aviz.moviezapplication/rtfz audio/midiz image/jpgz image/pictztext/xul)z.rtfz.midiz.midrfz.pictz.pctz.picz.xul)r rr rrrrrrrrr!Ú_default_mime_types�sˆ ú  ûÿþýüûúùø ÷ ö õ ô óòñðïîíìëêéèçæåäãâá à!ß"Þ#Ý$Ü%Û&Ú'Ù(Ø)×*Ö+Õ,Ô-Ó.Ò/Ñ0Ð1Ï2Î3Í4Ì5Ë6Ê7É8È9Ç:Æ;Å<Ä=Ã>Â?Á@ÀA¿B¾C½D¼E»FºG¹H¸I·J¶KµL´M³N²O±P°Q¯R®S­T¬U«VªW©X¨Y§Z¦[¥\¤]£^¢_¡` aŸbžc�dœe›fšg™h˜i—j–k•l”m“n’o‘p�q�rŽs�tŒu‹vŠw‰xˆy‡z†{…|„}ƒ~‚��ÿ�þ�ý�ü�û�ú�ù�ø �÷ � ðørgc sddl}d‰d‡fdd„ }z| tjdd…dgd¢¡\}}Wn|jy7}z |d|ƒWYd}~nd}~wwd}d}|D]\}}|d vrK|dƒq>|d vrRd}q>|d vrXd}q>|D],} |rqt| |ƒ} | sltd | ƒq[t| ƒq[t| |ƒ\} } | s€td | ƒq[td | d| ƒq[dS)Nra4Usage: 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. rQcs"tˆƒ|r t|ƒt |¡dS©N)ÚprintÚsysÚexit)ÚcodeÚmsg©ZUSAGErr!Úusageas z_main..usager?Zhle)ÚhelpZlenientÚ extension)z-hz--help)z-lz --lenient)z-ez --extensionz I don't know anything about typeztype:z encoding:)rQ)ÚgetoptrjÚargvÚerrorrrir) rrroZoptsÚargsrmrrqÚoptÚargZgtypeZguessr5rrnr!Ú_mainRs<  ÿ€ÿ  €  ørxÚ__main__rUrh)rYr+rjr0Z urllib.parser-Z_winapirÚ ImportErrorÚwinregrKÚ__all__rrr\rrrrr r r rgrxrVrrrr!ÚsD ÿ  ÿ  `     A. ÿ