mfc@sdZddlZddgZdZdZdZdZd Zd d gd Zdd Z gdZ dZ dZ dZedkre ndS(s%Mailcap file handling. See RFC 1524.iNtgetcapst findmatchcCsi}xtD]}yt|d}Wntk r?qnXt|}|jxE|jD]7\}}||kr|||s(RR,tfilter(R R;R R>t MIMEtypes((s/usr/lib64/python2.7/mailcap.pyR8s   c Cs`d}dt|}}x@||kr[||}|d}|dkr|dkrr|||d!}|d}n||}q||}|d}|dkr||}q|dkr||}q|dkr||}q|dkrJ|}x*||kr||d kr|d}qW|||!} |d}|t| |}q|d|}qW|S( NRiit%s\tsttt{t}(R t findparam( R0R;R<R=tresR.R/R6R5tname((s/usr/lib64/python2.7/mailcap.pyR9s6               cCsO|jd}t|}x,|D]$}|| j|kr#||Sq#WdS(NR*R(R"R (RKR=R/tp((s/usr/lib64/python2.7/mailcap.pyRIs    c Csddl}t}|jds0t|dSxtdt|jdD]}|j||d!}t|dkrdGHdS|d}|d}t||d|\}}|sdGtGHqLdG|GHtj |}|rLd G|GHqLqLWdS( Niiis"usage: mailcap [MIMEtype file] ...iR)sNo viewer found fors Executing:s Exit status:( tsysRtargvtshowRR RttypeRR:( RMR R.targsR;tfileR@R?tsts((s/usr/lib64/python2.7/mailcap.pyR7s&    "    cCsdGHxtD]}d|GHqWH|s5t}ndGHH|j}|jxg|D]_}|GH||}xG|D]?}|j}|jx|D]}d|G||GHqWHqtWqXWdS(NsMailcap files:s sMailcap entries:s %-15s(RRtkeystsort(R tfntckeysRPR>R?RTtk((s/usr/lib64/python2.7/mailcap.pyROs&          t__main__(t__doc__Rt__all__RRRRR+RR,R8R9RIR7ROt__name__(((s/usr/lib64/python2.7/mailcap.pyts     &