Your IP : 3.147.82.22


Current Path : /lib64/python2.7/
Upload File :
Current File : //lib64/python2.7/mimetypes.pyo

�
zfc	@sqdZddlZddlZddlZddlZyddlZWnek
r_dZnXddddddgZd	d
ddd
ddddg	Z	e
adadd-d��YZ
ed�Zed�Zed�Zed�Zdd�Zd�Zd�Ze�edkrmddlZdZdd�Zy/ejejddd d!d"g�\ZZWn#ejk
r�Zede�nXdZd#Z xWeD]O\Z!Z"e!d.kr�ed#�q�e!d/kr�d#Zq�e!d0kr�dZ q�q�WxxeD]mZ#e r.ee#e�Z$e$s&d*Ge#GHqfe$GHq�ee#e�\Z$Z%e$sUd*Ge#GHq�d+Ge$Gd,Ge%GHq�WndS(1s�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 (on Windows, the
  default values are taken from the registry)
read_mime_types(file) -- parse one file, return a dictionary or None
i����Nt
guess_typetguess_extensiontguess_all_extensionstadd_typetread_mime_typestinits/etc/mime.typess/etc/httpd/mime.typess/etc/httpd/conf/mime.typess/etc/apache/mime.typess/etc/apache2/mime.typess$/usr/local/etc/httpd/conf/mime.typess"/usr/local/lib/netscape/mime.typess/usr/local/etc/mime.typest	MimeTypescBsqeZdZd	ed�Zed�Zed�Zed�Zed�Zed�Z	ed�Z
ed�ZRS(
s�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.
    cCs�tst�ntj�|_tj�|_iif|_iif|_x-tj�D]\}}|j||t	�qYWx-t
j�D]\}}|j||t�q�Wx|D]}|j||�q�WdS(N(
tinitedRt
encodings_maptcopyt
suffix_mapt	types_mapt
types_map_invtitemsRtTruetcommon_typestFalsetread(tselft	filenameststricttextttypetname((s!/usr/lib64/python2.7/mimetypes.pyt__init__@s

cCsJ||j||<|j|j|g�}||krF|j|�ndS(s�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t
setdefaulttappend(RRRRtexts((s!/usr/lib64/python2.7/mimetypes.pyRNscCs�tj|�\}}|dkr�|jd�}|dkr@d	S|jdd|�}|dkrn|| }n
|| }d|ks�d|kr�d}n|dfStj|�\}}x3||jkr�tj||j|�\}}q�W||jkr"|j|}	tj|�\}}nd}	|jt	}
||
krO|
||	fS|j
�|
kru|
|j
�|	fS|r�d|	fS|jt}
||
kr�|
||	fS|j
�|
kr�|
|j
�|	fSd|	fSdS(
s: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.
        tdatat,it;t=t/s
text/plainN(NN(turllibt	splittypetfindtNonet	posixpathtsplitextR
RRRtlowerR(RturlRtschemetcommatsemiRtbaseRtencodingR((s!/usr/lib64/python2.7/mimetypes.pyR_s@

	
$



cCsr|j�}|jtj|g�}|snx@|jtj|g�D]"}||krE|j|�qEqEWn|S(s�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.
        (R'RRtgetRR(RRRt
extensionsR((s!/usr/lib64/python2.7/mimetypes.pyR�s cCs$|j||�}|sdS|dS(sGuess 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.
        iN(RR$(RRRR/((s!/usr/lib64/python2.7/mimetypes.pyR�s
cCs)t|��}|j||�WdQXdS(s�
        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.
        N(topentreadfp(RtfilenameRtfp((s!/usr/lib64/python2.7/mimetypes.pyR�sc	Cs�x�|j�}|sPn|j�}x9tt|��D]%}||ddkr8||3Pq8q8W|smqn|d|d}}x%|D]}|j|d||�q�WqWdS(s�
        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.
        it#it.N(treadlinetsplittrangetlenR(	RR3RtlinetwordstiRtsuffixestsuff((s!/usr/lib64/python2.7/mimetypes.pyR1�s
c	Cs
ts
dSd�}tj�}tjtjd���}x�||�D]�}y�tj||���}|jd�swwDntj|d�\}}|tjkr�wDny|j|�}Wnt	k
r�wDnX|j
|||�WdQXWqDtk
r�qDqDXqDWWdQXdS(s�
        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.
        Ncss`d}xStr[ytj||�}Wntk
r9PnXd|krN|Vn|d7}q	WdS(Nisi(Rt_winregtEnumKeytEnvironmentError(tmimedbR<tctype((s!/usr/lib64/python2.7/mimetypes.pyt
enum_types�s	
tR5sContent Type(R?tsystgetdefaultencodingtOpenKeytHKEY_CLASSES_ROOTt
startswithtQueryValueExtREG_SZtencodetUnicodeEncodeErrorRRA(	RRRDtdefault_encodingthkcrt
subkeynametsubkeytmimetypetdatatype((s!/usr/lib64/python2.7/mimetypes.pytread_windows_registry�s*
	

((t__name__t
__module__t__doc__RRRRRRRR1RU(((s!/usr/lib64/python2.7/mimetypes.pyR8s>cCs&tdkrt�ntj||�S(s�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(t_dbR$RR(R(R((s!/usr/lib64/python2.7/mimetypes.pyRs
cCs&tdkrt�ntj||�S(s�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(RYR$RR(RR((s!/usr/lib64/python2.7/mimetypes.pyR)s

cCs&tdkrt�ntj||�S(s�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(RYR$RR(RR((s!/usr/lib64/python2.7/mimetypes.pyR:s
cCs)tdkrt�ntj|||�S(siAdd 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(RYR$RR(RRR((s!/usr/lib64/python2.7/mimetypes.pyRJs
cCs�tat�}|dkr7tr.|j�nt}nx0|D](}tjj	|�r>|j
|�q>q>W|ja|ja|j
ta
|j
ta|adS(N(RRRR$R?RUt
knownfilestostpathtisfileRRR
RRRRY(tfilestdbtfile((s!/usr/lib64/python2.7/mimetypes.pyR[s	
	
		

cCsZyt|�}Wntk
r$dSX|�)t�}|j|t�|jtSWdQXdS(N(R0tIOErrorR$RR1RR(R`tfR_((s!/usr/lib64/python2.7/mimetypes.pyRos
	cCsidd6dd6dd6dd6dd6d	d
6aidd6d
d6dd6dd6ai�dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6dd#6d$d%6dd&6d'd(6d)d(6d*d+6d,d-6d.d/6d0d16dd26d3d46d3d56d6d76d8d96dd:6d;d<6dd=6d>d?6d@dA6ddB6dCdD6dEdF6dEdG6dHdI6dJdK6dLdM6dLdN6dLdO6dPdQ6dRdS6ddT6dUdV6dWdX6dYdZ6d[d\6d8d]6d8d^6d_d`6dPda6dbdc6ddde6dfdg6dfdh6didj6dWdk6dWdl6dWdm6dWdn6dodp6d)dq6d8dr6dds6ddt6dudv6dwdx6dydz6d{d|6d}d~6dwd6d�d�6dd�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6dd�6d�d�6d�d�6d�d�6d�d�6dbd�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�6d�d�6d3d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6aid�dO6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6adS(�Ns.svg.gzs.svgzs.tar.gzs.tgzs.tazs.tzs.tar.bz2s.tbz2s.tar.xzs.txztgzips.gztcompresss.Ztbzip2s.bz2txzs.xzsapplication/octet-streams.asapplication/postscripts.aisaudio/x-aiffs.aifs.aifcs.aiffsaudio/basics.ausvideo/x-msvideos.avis
text/plains.batsapplication/x-bcpios.bcpios.binsimage/x-ms-bmps.bmps.csapplication/x-cdfs.cdfsapplication/x-netcdfsapplication/x-cpios.cpiosapplication/x-cshs.cshstext/csss.cssstext/csvs.csvs.dllsapplication/mswords.docs.dotsapplication/x-dvis.dvismessage/rfc822s.emls.epss
text/x-setexts.etxs.exes	image/gifs.gifsapplication/x-gtars.gtars.hsapplication/x-hdfs.hdfs	text/htmls.htms.htmlsimage/vnd.microsoft.icons.icos	image/iefs.iefs
image/jpegs.jpes.jpegs.jpgsapplication/javascripts.jssapplication/jsons.jsons.kshsapplication/x-latexs.latexs
video/mpegs.m1vsapplication/x-troff-mans.mansapplication/x-troff-mes.mes.mhts.mhtmlsapplication/x-mifs.mifs.mjssvideo/quicktimes.movsvideo/x-sgi-movies.movies
audio/mpegs.mp2s.mp3s	video/mp4s.mp4s.mpas.mpes.mpegs.mpgsapplication/x-troff-mss.mss.ncs.nwss.os.objsapplication/odas.odasapplication/x-pkcs12s.p12sapplication/pkcs7-mimes.p7csimage/x-portable-bitmaps.pbmsapplication/pdfs.pdfs.pfxsimage/x-portable-graymaps.pgms.pls	image/pngs.pngsimage/x-portable-anymaps.pnmsapplication/vnd.ms-powerpoints.pots.ppasimage/x-portable-pixmaps.ppms.ppss.ppts.pss.pwzs
text/x-pythons.pysapplication/x-python-codes.pycs.pyos.qtsaudio/x-pn-realaudios.rasapplication/x-pn-realaudios.ramsimage/x-cmu-rasters.rassapplication/xmls.rdfsimage/x-rgbs.rgbsapplication/x-troffs.roffs
text/richtexts.rtxstext/x-sgmls.sgms.sgmlsapplication/x-shs.shsapplication/x-shars.shars.snds.sosapplication/x-wais-sources.srcsapplication/x-sv4cpios.sv4cpiosapplication/x-sv4crcs.sv4crcs
image/svg+xmls.svgsapplication/x-shockwave-flashs.swfs.tsapplication/x-tars.tarsapplication/x-tcls.tclsapplication/x-texs.texsapplication/x-texinfos.texis.texinfos
image/tiffs.tifs.tiffs.trstext/tab-separated-valuess.tsvs.txtsapplication/x-ustars.ustarstext/x-vcards.vcfsaudio/x-wavs.wavs
video/webms.webms.wizs.wsdlsimage/x-xbitmaps.xbmsapplication/vnd.ms-excels.xlbsapplication/excels.xlsstext/xmls.xmls.xpdlsimage/x-xpixmaps.xpms.xslsimage/x-xwindowdumps.xwdsapplication/zips.zips	image/jpgs
audio/midis.mids.midis
image/picts.pcts.pics.pictsapplication/rtfs.rtfstext/xuls.xul(R
RRR(((s!/usr/lib64/python2.7/mimetypes.pyt_default_mime_typeszs,


t__main__s4Usage: 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.
REcCs$tGH|r|GHntj|�dS(N(tUSAGERFtexit(tcodetmsg((s!/usr/lib64/python2.7/mimetypes.pytusage<sithlethelptlenientt	extensionis-hs--helps-ls	--lenients-es--extensions I don't know anything about typestype:s	encoding:((s-hs--help(s-ls	--lenient(s-es--extension(&RXR[RFR%R!R?tImportErrorR$t__all__RZRRRYRRRRRRRRRgRVtgetoptRiRmtargvtoptstargsterrorRlRRqtopttargtgtypetguessR-(((s!/usr/lib64/python2.7/mimetypes.pyt<module>st

		�		�
	



?>