Ñò §ÚêLc@s¬dZddkZddgZd„Zd„Zd„Zd„Zd „Zd d gd „Zdd „Z gd„Z d„Z d„Z d„Zedjo e ƒndS(s%Mailcap file handling. See RFC 1524.iÿÿÿÿNtgetcapst findmatchcCsªh}xtƒD]’}yt|dƒ}Wntj o qnXt|ƒ}|iƒxG|iƒD]9\}}||jo|||dtijotid}nd}|ddddg}|S( s7Return a list of all mailcap files found on the system.tMAILCAPSt:tHOMEt.s /.mailcaps /etc/mailcaps/usr/etc/mailcaps/usr/local/etc/mailcap(tostenvirontsplit(tstrtmailcapsthome((s/usr/lib64/python2.6/mailcap.pyR"s   cCsHh}x;|iƒ}|pPn|ddjp|iƒdjoq n|}xA|ddjo/|iƒ}|p d}n|d |}qUWt|ƒ\}}|o|pq n|idƒ}x.tt|ƒƒD]}||iƒ||t|d||ƒ}|oti|ƒdjoqqjnt|||||ƒ}||fSWdS(sFind 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. ttestiN(NN(tlookuptsubstRtsystemR,( R tMIMEtypeR tfilenametplisttentriesteR7tcommand((s/usr/lib64/python2.6/mailcap.pyRŠs    cCs‹g}||jo|||}n|idƒ}|dd}||jo|||}n|dj ot|d„|ƒ}n|S(NRis/*cSs ||jS(((R?R ((s/usr/lib64/python2.6/mailcap.pyt§s(RR,tfilter(R R;R R>t MIMEtypes((s/usr/lib64/python2.6/mailcap.pyR8žs   c Csqd}dt|ƒ}}xQ||joC||}|d}|djo:|djo|||d!}|d}n||}q||}|d}|djo||}q|djo||}q|djo||}q|djod|}x-||jo||d jo|d}qÿW|||!} |d}|t| |ƒ}q|d|}qW|S( NRiit%s\tsttt{t}(R t findparam( R0R;R<R=tresR.R/R6R5tname((s/usr/lib64/python2.6/mailcap.pyR9ªs:           cCsQ|iƒd}t|ƒ}x.|D]&}|| iƒ|jo ||Sq#WdS(NR*R(R"R (RKR=R/tp((s/usr/lib64/python2.6/mailcap.pyRIÊs  c Csüddk}tƒ}|idpt|ƒdSxÃtdt|iƒdƒD]¦}|i||d!}t|ƒdjo dGHdS|d}|d}t||d|ƒ\}}|p dGtGHqNdG|GHti |ƒ}|o d G|GHqNqNWdS( Niÿÿÿÿiis"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.6/mailcap.pyR7Õs(       cCsÁdGHxtƒD]}d|GHqWH|p tƒ}ndGHH|iƒ}|iƒxg|D]_}|GH||}xG|D]?}|iƒ}|iƒx|D]}d|G||GHq™WHqvWqZWdS(NsMailcap files:s sMailcap entries:s %-15s(RRtkeystsort(R tfntckeysRPR>R?RTtk((s/usr/lib64/python2.6/mailcap.pyROës.        t__main__(t__doc__Rt__all__RRRRR+RR,R8R9RIR7ROt__name__(((s/usr/lib64/python2.6/mailcap.pyts     &