AlkantarClanX12

Your IP : 18.118.19.123


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/mailcap.cpython-35.opt-2.pyc



���]��@s�ddlZddlZddgZdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	ddgdd�Z
ddd�Zgdd�Zdd�Z
dd�Zdd�Zedkr�e�dS)�N�getcaps�	findmatchcCs"d|krd|dfSdSdS)N�linenor�)rr�)�entryrr�,/opt/alt/python35/lib64/python3.5/mailcap.py�lineno_sort_key	sr	cCs�i}d}x�t�D]�}yt|d�}Wntk
rFwYnX|�t||�\}}WdQRXxE|j�D]7\}}||kr�|||<qw|||||<qwWqW|S)Nr�r)�listmailcapfiles�open�OSError�_readmailcapfile�items)�capsrZmailcap�fpZmorecaps�key�valuerrrrs


cCspdtjkr1tjd}|jtj�}n;dtjkrPtjd}nd}|ddddg}|S)NZMAILCAPS�HOME�.z	/.mailcapz/etc/mailcapz/usr/etc/mailcapz/usr/local/etc/mailcap)�os�environ�split�pathsep)ZpathstrZmailcaps�homerrrr-s

rcCs,tjdtd�t|d�\}}|S)Nz2readmailcapfile is deprecated, use getcaps instead�)�warnings�warn�DeprecationWarningr)rr�_rrr�readmailcapfile?s	
r c	Csai}xN|j�}|sP|ddks	|j�dkrAq	|}xF|d
d�dkr�|j�}|sxd}|dd�|}qJWt|�\}}|o�|s�q	|dk	r�||d<|d7}|jd	�}x.tt|��D]}||j�||<q�Wd	j|�j�}||krF||j|�q	|g||<q	W||fS)Nr�#�rz\
�
rr�/���r%)	�readline�strip�	parseliner�range�len�join�lower�append)	rrr�lineZnextliner�fields�types�jrrrrGs6	"

rc
Cs1g}dt|�}}x?||krZt|||�\}}|j|�|d}qWt|�dkrqdS|d|d|dd�}}}d|i}x�|D]y}|jd�}|dkr�|}d}	n0|d|�j�}||dd�j�}	||krq�|	||<q�W||fS)Nrrr�view�=r")NN)r*�
parsefieldr-�findr')
r.r/�i�n�fieldrr2�restZfkeyZfvaluerrrr(ps*
&
	r(cCsp|}xM||krU||}|dkr/Pq	|dkrH|d}q	|d}q	W|||�j�|fS)N�;�\rr)r')r.r6r7�start�crrrr4�s

r4r2z	/dev/nullc	Cs�t|||�}xn|D]f}d|kr_t|d||�}|r_tj|�dkr_qt|||||�}||fSWdS)N�testr)NN)�lookup�substr�system)	r�MIMEtyper�filename�plist�entries�er>�commandrrrr�s	
cs�g}||kr |||}|jd�}|dd}||krW|||}�dk	r|�fdd�|D�}t|dt�}|S)Nr$rz/*cs"g|]}�|kr|�qSrr)�.0rF)rrr�
<listcomp>�s	zlookup.<locals>.<listcomp>r)r�sortedr	)rrBrrEZ	MIMEtypesr)rrr?�sr?c
Cscd}dt|�}}xC||kr^||}|d}|dkr|dkrr|||d�}|d}||}q||}|d}|dkr�||}q|dkr�||}q|dkr�||}q|dkrM|}x*||kr||d	kr|d}q�W|||�}	|d}|t|	|�}q|d|}qW|S)
Nr"rr�%r;�s�t�{�})r*�	findparam)
r8rBrCrD�resr6r7r=r<�namerrrr@�s6









r@cCs[|j�d}t|�}x8|D]0}|d|�j�|kr#||d�Sq#WdS)Nr3r")r,r*)rRrDr7�prrrrP�s
rPc	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|�qRWdS)	Nrrrz"usage: mailcap [MIMEtype file] ...r2zNo viewer found forz
Executing:zExit status:)�sysr�argv�showr)r*�printr�typerrA)	rTrr6�argsrB�filerGrF�stsrrrr>�s&	
"



r>cCs�td�xt�D]}td|�qWt�|sBt�}td�t�t|�}xl|D]d}t|�||}xG|D]?}t|�}x#|D]}td|||�q�Wt�q�WqfWdS)NzMailcap files:�	zMailcap entries:z  %-15s)rWrrrJ)r�fnZckeysrXrErF�keys�krrrrVs"
	





rV�__main__)rr�__all__r	rrr rr(r4rr?r@rPr>rV�__name__rrrr�<module>s"
)