???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................
YfoQ                 @   s  d  Z  d d l Z d d l Z d d l Z d d l Z y d d l Z Wn e k
 r` d Z Yn Xd d d d d d g Z	 d	 d
 d d d d d d d g	 Z
 d a d a Gd d   d  Z d d d  Z d d d  Z d d d  Z d d d  Z d d d  Z d d   Z d d   Z e   e d k rd d l Z d Z d d  d!  Z y5 e j e j d" d  d# d$ d% d& g  \ Z Z Wn5 e j k
 rZ z e d" e  WYd d Z [ Xn Xd" Z d Z xT e D]L \ Z  Z! e  d0 k re d  qe  d1 k r
d Z qe  d2 k rd" Z qWx e D]| Z" e ree e" e  Z# e# sXe$ d- e"  qe$ e#  q'e e" e  \ Z# Z% e# se$ d- e"  q'e$ d. e# d/ e%  q'Wd S)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   e  Z d  Z d Z f  d d d  Z d d d  Z d d d  Z d d	 d
  Z d d d  Z d d d  Z	 d d d  Z
 d d d  Z d S)	MimeTypeszMIME-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.
    Tc             C   s   t  s t   t j   |  _ t j   |  _ i  i  f |  _ i  i  f |  _ x- t j   D] \ } } |  j | | d  qV Wx- t	 j   D] \ } } |  j | | d  q Wx | D] } |  j
 | |  q Wd  S)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/python35/lib64/python3.5/mimetypes.py__init__@   s    zMimeTypes.__init__c             C   sG   | |  j  | | <|  j | j | g   } | | k rC | j |  d S)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)r   r   r   r   Zextsr   r   r   r   N   s    zMimeTypes.add_typec             C   s  t  j j |  \ } } | d k r | j d  } | d k  rC d S| j d d |  } | d k rw | d |  } n | d |  } d | k s d | k r d } | d f St j |  \ } } x3 | |  j k r t j | |  j |  \ } } q W| |  j k r.|  j | }	 t j |  \ } } n d }	 |  j d	 }
 | |
 k r[|
 | |	 f S| j	   |
 k r|
 | j	   |	 f S| rd |	 f S|  j d
 }
 | |
 k r|
 | |	 f S| j	   |
 k r|
 | j	   |	 f Sd |	 f Sd 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.
        data,r   N;=/z
text/plainTF)NN)
urllibparseZ	splittypefind	posixpathsplitextr   r
   r   lower)r   urlr   schemeZcommaZsemir   baser   encodingr   r   r   r   r   _   s@    
$
zMimeTypes.guess_typec             C   sl   | j    } |  j d j | g   } | sh x: |  j d j | g   D] } | | k rE | j |  qE W| 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   )r   r   r   
extensionsr   r   r   r   r      s     zMimeTypes.guess_all_extensionsc             C   s$   |  j  | |  } | s d S| d 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.
        Nr   )r   )r   r   r   r-   r   r   r   r      s    zMimeTypes.guess_extensionc          
   C   s0   t  | d d  } |  j | |  Wd QRXd S)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+   zutf-8N)openreadfp)r   filenamer   fpr   r   r   r      s    zMimeTypes.readc       	      C   s   x | j    } | s P| j   } x< t t |   D]( } | | d d k r5 | | d  =Pq5 W| sj q | d | d d  } } x% | D] } |  j | d | |  q Wq Wd S)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   )	r   r1   r   lineZwordsir   suffixesZsuffr   r   r   r/      s    zMimeTypes.readfpc             C   s   t  s
 d Sd d   } t  j t  j d   } x | |  D] } yo t  j | |  V } | j d  sk w; t  j | d  \ } } | t  j k r w; |  j | | |  Wd QRXWq; t k
 r w; Yq; Xq; WWd QRXd S)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             s   sX   d } xK y t  j |  |  } Wn t k
 r4 PYn Xd | k rF | V| d 7} q	 Wd  S)Nr    r3   )_winregZEnumKeyEnvironmentError)Zmimedbr:   Zctyper   r   r   
enum_types   s    z3MimeTypes.read_windows_registry.<locals>.enum_types r4   zContent Type)r=   OpenKeyZHKEY_CLASSES_ROOT
startswithZQueryValueExZREG_SZr   r>   )r   r   r?   ZhkcrZ
subkeynameZsubkeyZmimetypeZdatatyper   r   r   read_windows_registry   s     
zMimeTypes.read_windows_registryN)__name__
__module____qualname____doc__r   r   r   r   r   r   r/   rC   r   r   r   r   r   8   s   >r   Tc             C   s#   t  d k r t   t  j |  |  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   )r(   r   r   r   r   r     s    c             C   s#   t  d k r t   t  j |  |  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)rH   r   r   )r   r   r   r   r   r   $  s    c             C   s#   t  d k r t   t  j |  |  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)rH   r   r   )r   r   r   r   r   r   5  s    c             C   s&   t  d k r t   t  j |  | |  S)ai  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)rH   r   r   )r   r   r   r   r   r   r   E  s    c             C   s   d a  t   } |  d  k r1 t r+ | j   t }  x- |  D]% } t j j |  r8 | j |  q8 W| j	 a	 | j
 a
 | j d a | j d a | a d  S)NTF)r	   r   r=   rC   
knownfilesospathisfiler   r
   r   r   r   rH   )filesdbfiler   r   r   r   V  s    	
		c             C   s_   y t  |   } Wn t k
 r( d  SYn X| ) t   } | j | d  | j d SWd  QRXd  S)NT)r.   OSErrorr   r/   r   )rO   frN   r   r   r   r   j  s    		c               C   s  d d d d d d d d d d d	 d
 i a  d d d d d d d d i a 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/ d0 d1 d2 d d3 d4 d5 d4 d6 d7 d8 d9 d: d d; d< d= d d> d? d@ dA dB d  dC dD dE dF dG dF dH dI dJ dK dL dM dN dM dO dM dP dQ dR d  dS dT dU dV dW dX dY dX dZ d[ d\ d] d^ d9 d_ d9 d` da db dc dd de df dg dh dg di dj dk dV dl dV dm dV dn dV do dp dq d) dr d9 ds d dt d du dv dw dx dy dz d{ d| d} d~ d dx 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 dc 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 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 d4 d d d d d d d d d d d d d d d d d d d d d d i a dO d d d d d d d d d d d d d d d i a d  S)Nz.svgzz.svg.gzz.tgzz.tar.gzz.tazz.tzz.tbz2z.tar.bz2z.txzz.tar.xzz.gzZgzipz.Zcompressz.bz2Zbzip2z.xzZxzz.azapplication/octet-streamz.aizapplication/postscriptz.aifzaudio/x-aiffz.aifcz.aiffz.auzaudio/basicz.avizvideo/x-msvideoz.batz
text/plainz.bcpiozapplication/x-bcpioz.binz.bmpzimage/x-ms-bmpz.cz.cdfzapplication/x-cdfzapplication/x-netcdfz.cpiozapplication/x-cpioz.cshzapplication/x-cshz.cssztext/cssz.csvztext/csvz.dllz.doczapplication/mswordz.dotz.dvizapplication/x-dviz.emlzmessage/rfc822z.epsz.etxztext/x-setextz.exez.gifz	image/gifz.gtarzapplication/x-gtarz.hz.hdfzapplication/x-hdfz.htmz	text/htmlz.htmlz.icozimage/vnd.microsoft.iconz.iefz	image/iefz.jpez
image/jpegz.jpegz.jpgz.jszapplication/javascriptz.kshz.latexzapplication/x-latexz.m1vz
video/mpegz.m3uzapplication/vnd.apple.mpegurlz.m3u8z.manzapplication/x-troff-manz.mezapplication/x-troff-mez.mhtz.mhtmlz.mifzapplication/x-mifz.movzvideo/quicktimez.moviezvideo/x-sgi-moviez.mp2z
audio/mpegz.mp3z.mp4z	video/mp4z.mpaz.mpez.mpegz.mpgz.mszapplication/x-troff-msz.ncz.nwsz.oz.objz.odazapplication/odaz.p12zapplication/x-pkcs12z.p7czapplication/pkcs7-mimez.pbmzimage/x-portable-bitmapz.pdfzapplication/pdfz.pfxz.pgmzimage/x-portable-graymapz.plz.pngz	image/pngz.pnmzimage/x-portable-anymapz.potzapplication/vnd.ms-powerpointz.ppaz.ppmzimage/x-portable-pixmapz.ppsz.pptz.psz.pwzz.pyztext/x-pythonz.pyczapplication/x-python-codez.pyoz.qtz.razaudio/x-pn-realaudioz.ramzapplication/x-pn-realaudioz.raszimage/x-cmu-rasterz.rdfzapplication/xmlz.rgbzimage/x-rgbz.roffzapplication/x-troffz.rtxztext/richtextz.sgmztext/x-sgmlz.sgmlz.shzapplication/x-shz.sharzapplication/x-sharz.sndz.soz.srczapplication/x-wais-sourcez.sv4cpiozapplication/x-sv4cpioz.sv4crczapplication/x-sv4crcz.svgzimage/svg+xmlz.swfzapplication/x-shockwave-flashz.tz.tarzapplication/x-tarz.tclzapplication/x-tclz.texzapplication/x-texz.texizapplication/x-texinfoz.texinfoz.tifz
image/tiffz.tiffz.trz.tsvztext/tab-separated-valuesz.txtz.ustarzapplication/x-ustarz.vcfztext/x-vcardz.wavzaudio/x-wavz.webmz
video/webmz.wizz.wsdlz.xbmzimage/x-xbitmapz.xlbzapplication/vnd.ms-excelz.xlszapplication/excelz.xmlztext/xmlz.xpdlz.xpmzimage/x-xpixmapz.xslz.xwdzimage/x-xwindowdumpz.zipzapplication/zipz	image/jpgz.midz
audio/midiz.midiz.pctz
image/pictz.picz.pictz.rtfzapplication/rtfz.xulztext/xul)r   r
   r   r   r   r   r   r   _default_mime_typesu  s$   	rS   __main__a4  Usage: 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@   c             C   s+   t  t  | r t  |  t j |   d  S)N)printUSAGEsysexit)codemsgr   r   r   usage7  s    
 
r[   r3   ZhlehelpZlenient	extension-h--help-l	--lenient-e--extensionz I don't know anything about typeztype:z	encoding:)r^   r_   )r`   ra   )rb   rc   )&rG   rJ   rW   r%   Zurllib.parser"   winregr=   ImportError__all__rI   r	   rH   r   r   r   r   r   r   r   rS   rD   ZgetoptrV   r[   argvZoptsargserrorrZ   r   r]   ZoptargZgtypeZguessrU   r+   r   r   r   r   <module>   st   		 	
  