JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbro h X@sdZddlZddlZddlZddlZzddlmZWn ey%dZYnwzddl Z Wn ey7dZ YnwgdZ gdZ da daGdddZdd d Zdd d ZdddZdddZdddZddZddZeddZedkr|edSdS)aGuess 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) knownfilesinited MimeTypes guess_typeguess_all_extensionsguess_extensionadd_typeinitread_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@sleZdZdZdddZdddZddd Zdd d Zdd d ZdddZ dddZ dddZ e ddZ dS)rzMIME-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. TcCststt|_t|_iif|_iif|_t D] \}}| ||dqt D] \}}| ||dq-|D]}| ||q;dSNTF)rr _encodings_map_defaultcopyr _suffix_map_defaultr r types_map_inv_types_map_defaultitemsr _common_types_defaultread)self filenamesstrictexttypenamerr0/opt/alt/python310/lib64/python3.10/mimetypes.py__init__Hs    zMimeTypes.__init__cCs:||j||<|j||g}||vr||dSdS)aAdd 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 setdefaultappend)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|rd| 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) osfspathurllibparseZ _splittypefind posixpathsplitextlowerr r r) rurlrZschemeZcommaZsemirbaserZ ext_lowerencodingrrrr!rgs>         zMimeTypes.guess_typecCsP|}t|jd|g}|s&|jd|gD] }||vr%||q|S)aGuess 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)r2listrgetr$)rrr extensionsrrrr!rs  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!rs zMimeTypes.guess_extensioncCs>t|dd}|||WddS1swYdS)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-8r5N)openreadfp)rfilenamerfprrr!rs"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.)readlinesplitrangelenr ) rr>rlineZwordsirsuffixesZsuffrrr!r<s  zMimeTypes.readfpcsHtstsdSj}|rfdd}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||dS)NT)r )rrrrr!sz1MimeTypes.read_windows_registry..)r_winregr _read_windows_registry)rrr rrIr!read_windows_registrys   zMimeTypes.read_windows_registryc Csdd}ttjdZ}||D]L}zAt||1}|ds( WdWqt|d\}}|tjkr> WdWq|||Wdn1sMwYWqty\YqwWddS1shwYdS)NcssFd} zt||}Wn tyYdSwd|vr|V|d7}q)NrTr?)rKZEnumKeyOSError)ZmimedbrGZctyperrr! enum_typess z4MimeTypes._read_windows_registry..enum_typesrAz Content Type)rKOpenKeyZHKEY_CLASSES_ROOT startswithZ QueryValueExZREG_SZrO)clsr rPZhkcrZ subkeynameZsubkeyZmimetypeZdatatyperrr!rLs,     "z MimeTypes._read_windows_registryN)rTT)__name__ __module__ __qualname____doc__r"r rrrrr<rM classmethodrLrrrr!r@s    =   rTcCtdurtt||S)aGuess 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[)aGuess 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 rrrrrr!r6s  rcCr[)aGuess 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  rcCstdurtt|||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 cCsda|dus tdurt}||durt}n tt|}nt}|D] }tj|r0| |q#|j a |j a |j da |j da |adSr)rr\rrMrr6r+pathisfilerr r rr)filesdbfilerrr!r hs"    r cCsjzt|dd}Wn tyYdSw|t}||d|jdWdS1s.wYdS)Nr9r:T)r;rOrr<r)rbfrarrr!r s  $r c Csdddddddaadddd d d aaid d dd dddddddddddddddddddddddddd d!d"d#d$id%d&d'd&d(d&d)d*d+d*d,d-d.d-d/d0d1d0d2d0d3d0d4d0d5d6d7d8d9d:d;d<d=d>id?d@dAdBdCdDdEdFdGdHdIdJdKdJdLdMdNdMdOdPdQdRdSdRdTdUdVdWdXdYdZd[d\d]id^d_d`dadbdcdddedfdedgdhdidhdjdhdkdldmdndodpdqdrdsdtdudvdwdvdxdvdydvidzd{d|d}d~d}ddddddddddddddddddddddddddddiddddddddddddddddddddddddddddddddddidddddddddddddddddd“dd“dd“dd“ddǓddɓdd˓dd˓ddΓiddΓddΓddΓddΓddΓddՓddדddٓddۓddݓddݓddddddddddddddddddddaadddddddddaadS)Nz.svg.gzz.tar.gzz.tar.bz2z.tar.xz)z.svgzz.tgzz.tazz.tzz.tbz2z.txzZgzipcompressZbzip2Zxzbr)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_typess         !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   rgc sddl}ddfdd }z|tjdddgd\}}Wn|jy7}z |d|WYd}~nd}~wwd}d}|D]\}}|d vrK|dq>|d vrRd}q>|d vrXd}q>|D],} |rqt| |} | sltd | q[t| q[t| |\} } | std | 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|dSN)printsysexit)codemsgZUSAGErr!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)getoptrjargverrorrrir) rrroZoptsargsrmrrqoptargZgtypeZguessr5rrnr!_mainRs<      rx__main__rUrh)rYr+rjr0Z urllib.parser-Z_winapir ImportErrorwinregrK__all__rrr\rrrrr r r rgrxrVrrrr!sD     `     A.