Hacked By AnonymousFox

Current Path : /opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/__pycache__/mailcap.cpython-33.pyo

�
��f
c@s�dZddlZddgZdd�Zdd�Zdd	�Zd
d�Zdd
�Zddgdd�Zddd�Z
gdd�Zdd�Zdd�Z
dd�Zedkr�e
�ndS(u%Mailcap file handling.  See RFC 1524.iNugetcapsu	findmatchcCs�i}x�t�D]�}yt|d�}Wntk
r@wYnX|�t|�}WdQXxE|j�D]7\}}||kr�|||<qg|||||<qgWqW|S(u�Return a dictionary containing the mailcap database.

    The dictionary maps a MIME type (in all lowercase, e.g. 'text/plain')
    to a list of dictionaries corresponding to mailcap entries.  The list
    collects all the entries for that MIME type from all available mailcap
    files.  Each dictionary contains key-value pairs for that MIME type,
    where the viewing command is stored with the key "view".

    urN(ulistmailcapfilesuopenuIOErrorureadmailcapfileuitems(ucapsumailcapufpumorecapsukeyuvalue((u,/opt/alt/python33/lib64/python3.3/mailcap.pyugetcaps	s


cCspdtjkr1tjd}|jtj�}n;dtjkrPtjd}nd}|ddddg}|S(u7Return a list of all mailcap files found on the system.uMAILCAPSuHOMEu.u	/.mailcapu/etc/mailcapu/usr/etc/mailcapu/usr/local/etc/mailcap(uosuenvironusplitupathsep(upathstrumailcapsuhome((u,/opt/alt/python33/lib64/python3.3/mailcap.pyulistmailcapfiles"s

ulistmailcapfilescCsFi}x9|j�}|sPn|ddks	|j�dkrGq	n|}xI|d	d�dkr�|j�}|s�d}n|dd
�|}qPWt|�\}}|o�|s�q	n|jd�}x.tt|��D]}||j�||<q�Wdj|�j�}||kr2||j|�q	|g||<q	|S(u�Read a mailcap file and return a dictionary keyed by MIME type.

    Each MIME type is mapped to an entry consisting of a list of
    dictionaries; the list will contain more than one such dictionary
    if a given MIME type appears more than once in the mailcap file.
    Each dictionary contains key-value pairs for that MIME type, where
    the viewing command is stored with the key "view".
    iu#uiNu\
u
u/i����i����(	ureadlineustripu	parselineuspliturangeulenujoinuloweruappend(ufpucapsulineunextlineukeyufieldsutypesuj((u,/opt/alt/python33/lib64/python3.3/mailcap.pyureadmailcapfile5s0	"	ureadmailcapfilec
Cs2g}dt|�}}x?||krZt|||�\}}|j|�|d}qWt|�dkrqdS|d|d|dd�}}}i|d6}x�|D]y}|jd�}|dkr�|}d}	n0|d|�j�}||dd�j�}	||krq�|	||<q�W||fS(	u�Parse one entry in a mailcap file and return a dictionary.

    The viewing command is stored as the value with the key "view",
    and the rest of the fields produce key-value pairs in the dict.
    iiiNuviewu=u(NN(ulenu
parsefielduappenduNoneufindustrip(
ulineufieldsuiunufieldukeyuviewurestufkeyufvalue((u,/opt/alt/python33/lib64/python3.3/mailcap.pyu	parseline[s*
&

	u	parselinecCsp|}xM||krU||}|dkr/Pq	|dkrH|d}q	|d}q	W|||�j�|fS(u/Separate one key-value pair in a mailcap entry.u;u\ii(ustrip(ulineuiunustartuc((u,/opt/alt/python33/lib64/python3.3/mailcap.pyu
parsefieldzs

u
parsefielduviewu	/dev/nullc	Cs�t|||�}xt|D]l}d|kret|d||�}|retj|�dkreqqent|||||�}||fSWdS(uFind a match for a mailcap entry.

    Return a tuple containing the command line, and the mailcap entry
    used; (None, None) if no match is found.  This may invoke the
    'test' command of several matching entries before deciding which
    entry to use.

    utestiN(NN(ulookupusubstuosusystemuNone(	ucapsuMIMEtypeukeyufilenameuplistuentriesueutestucommand((u,/opt/alt/python33/lib64/python3.3/mailcap.pyu	findmatch�s	
	cs�g}||kr#|||}n|jd�}|dd}||kr]|||}n�dk	r��fdd�|D�}n|S(Nu/iu/*cs"g|]}�|kr|�qS(((u.0ue(ukey(u,/opt/alt/python33/lib64/python3.3/mailcap.pyu
<listcomp>�s	ulookup.<locals>.<listcomp>(usplituNone(ucapsuMIMEtypeukeyuentriesu	MIMEtypes((ukeyu,/opt/alt/python33/lib64/python3.3/mailcap.pyulookup�sulookupc
Csfd}dt|�}}xF||kra||}|d}|dkr�|dkru|||d�}|d}n||}q||}|d}|dkr�||}q|dkr�||}q|dkr�||}q|dkrP|}x*||kr||d	kr|d}q�W|||�}	|d}|t|	|�}q|d|}qW|S(
Nuiiu%u\usutu{u}(ulenu	findparam(
ufielduMIMEtypeufilenameuplisturesuiunucustartuname((u,/opt/alt/python33/lib64/python3.3/mailcap.pyusubst�s6









usubstcCs[|j�d}t|�}x8|D]0}|d|�j�|kr#||d�Sq#WdS(Nu=u(ulowerulen(unameuplistunup((u,/opt/alt/python33/lib64/python3.3/mailcap.pyu	findparam�s
u	findparamc	Csddl}t�}|jdd�s6t|�dSx�tdt|j�d�D]�}|j||d�}t|�dkr�td�dS|d}|d}t||d|�\}}|s�tdt�qRtd|�t	j
|�}|rRtd|�qRqRWdS(	Niiiu"usage: mailcap [MIMEtype file] ...uviewuNo viewer found foru
Executing:uExit status:(usysugetcapsuargvushowurangeulenuprintu	findmatchutypeuosusystem(	usysucapsuiuargsuMIMEtypeufileucommandueusts((u,/opt/alt/python33/lib64/python3.3/mailcap.pyutest�s&	
"



utestcCs�td�xt�D]}td|�qWt�|sEt�}ntd�t�t|�}xl|D]d}t|�||}xG|D]?}t|�}x#|D]}td|||�q�Wt�q�WqiWdS(NuMailcap files:u	uMailcap entries:u  %-15s(uprintulistmailcapfilesugetcapsusorted(ucapsufnuckeysutypeuentriesueukeysuk((u,/opt/alt/python33/lib64/python3.3/mailcap.pyushow�s"






ushowu__main__(u__doc__uosu__all__ugetcapsulistmailcapfilesureadmailcapfileu	parselineu
parsefieldu	findmatchuNoneulookupusubstu	findparamutestushowu__name__(((u,/opt/alt/python33/lib64/python3.3/mailcap.pyu<module>s& 

Hacked By AnonymousFox1.0, Coded By AnonymousFox