tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
L\¬Qc@sªdZddlZddgZd„Zd„Zd„Zd„Zd    „Zd
d gd „Zdd „Z
gd„Z d„Z d„Z d„Zedkr¦e ƒndS(s%Mailcap file handling.  See RFC 1524.iÿÿÿÿNtgetcapst    findmatchcCs¦i}x™tƒD]Ž}yt|dƒ}Wntk
r?qnXt|ƒ}|jƒxE|jƒD]7\}}||krˆ|||<qc|||||<qcWqW|S(s 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".
 
    tr(tlistmailcapfilestopentIOErrortreadmailcapfiletcloset    iteritems(tcapstmailcaptfptmorecapstkeytvalue((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyR    s
 
  cCsmdtjkr.tjd}|jdƒ}n;dtjkrMtjd}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((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyR"s 
 cCs:i}x-|jƒ}|sPn|ddks    |jƒdkrGq    n|}x=|ddkrŒ|jƒ}|s{d}n|d |}qPWt|ƒ\}}|o¨|s±q    n|jdƒ}x.tt|ƒƒD]}||jƒ||<qÓWdj|ƒjƒ}||kr&||j|ƒq    |g||<q    |S(s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".
    it#tiþÿÿÿs\
s
t/(    treadlinetstript    parselineRtrangetlentjointlowertappend(R R    tlinetnextlineR tfieldsttypestj((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyR5s0     "       c
Cs g}dt|ƒ}}x?||krZt|||ƒ\}}|j|ƒ|d}qWt|ƒdkrqdS|d|d|d}}}i|d6}xu|D]m}|jdƒ}|dkrÕ|}d}    n$|| jƒ}||djƒ}    ||krq¥|    ||<q¥W||fS(    sÈ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.
    iiitviewt=RN(NN(R t
parsefieldR#tNonetfindR(
R$R&titntfieldR R)tresttfkeytfvalue((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyR[s*          cCsm|}xM||krU||}|dkr/Pq    |dkrH|d}q    |d}q    W|||!jƒ|fS(s/Separate one key-value pair in a mailcap entry.t;s\ii(R(R$R.R/tstarttc((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyR+zs
   R)s    /dev/nullc    Cst|||ƒ}xt|D]l}d|kret|d||ƒ}|retj|ƒdkreqqent|||||ƒ}||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((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyRŠs           cCs…g}||kr#|||}n|jdƒ}|dd}||kr]|||}n|dk    rt|d„|ƒ}n|S(NRis/*cSs
||kS(N((R?R ((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyt<lambda>§s(RR,tfilter(R    R;R R>t    MIMEtypes((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyR8žs   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}qóW|||!}    |d}|t|    |ƒ}q|d|}qW|S(
NRiit%s\tsttt{t}(R t    findparam(
R0R;R<R=tresR.R/R6R5tname((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyR9ªs6
 
 
 
 
cCsO|jƒd}t|ƒ}x,|D]$}|| jƒ|kr#||Sq#WdS(NR*R(R"R (RKR=R/tp((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyRIÊs    c    Csôddl}tƒ}|jds0t|ƒdSx½tdt|jƒdƒD] }|j||d!}t|ƒdkrdGHdS|d}|d}t||d|ƒ\}}|sÂdGtGHqLdG|GHtj    |ƒ}|rLd    G|GHqLqLWdS(
Niÿÿÿÿiis"usage: mailcap [MIMEtype file] ...iR)sNo viewer found fors
Executing:s Exit status:(
tsysRtargvtshowRR RttypeRR:(    RMR    R.targsR;tfileR@R?tsts((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyR7Õs&      
"
 
     cCs¿dGHxtƒD]}d|GHqWH|s5tƒ}ndGHH|jƒ}|jƒxg|D]_}|GH||}xG|D]?}|jƒ}|jƒx|D]}d|G||GHq—WHqtWqXWdS(NsMailcap files:s    sMailcap entries:s  %-15s(RRtkeystsort(R    tfntckeysRPR>R?RTtk((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyROës&   
 
 
 t__main__(t__doc__Rt__all__RRRRR+RR,R8R9RIR7ROt__name__(((sO/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/mailcap.pyt<module>s              &