%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/__pycache__/mailcap.cpython-38.pyc

U

na@sdZddlZddlZddgZddZddZdd	Zd
dZdd
ZddZ	ddZ
ddgfddZd ddZgfddZ
ddZddZddZedkredS)!z%Mailcap file handling.  See RFC 1524.Ngetcaps	findmatchcCsd|krd|dfSdSdS)Nlinenor)r)entryrr#/usr/local/lib/python3.8/mailcap.pylineno_sort_key	sr	c
Csi}d}tD]~}zt|d}Wntk
r8YqYnX|t||\}}W5QRX|D]*\}}||krz|||<q`|||||<q`q|S)aReturn 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".

    rr)listmailcapfilesopenOSError_readmailcapfileitems)capsrZmailcapfpZmorecapskeyvaluerrrrs



cCsPdtjkr"tjd}|tj}n*dtjkr8tjd}nd}|ddddg}|S)z7Return a list of all mailcap files found on the system.ZMAILCAPSHOME.z	/.mailcapz/etc/mailcapz/usr/etc/mailcapz/usr/local/etc/mailcap)osenvironsplitpathsep)ZpathstrZmailcapshomerrrr-s


rcCs tdtdt|d\}}|S)z?Read a mailcap file and return a dictionary keyed by MIME type.z2readmailcapfile is deprecated, use getcaps insteadN)warningswarnDeprecationWarningr)rr_rrrreadmailcapfile?sr c	Csi}|}|sq|ddks|dkr,q|}|dddkrb|}|sPd}|dd|}q0t|\}}|r|sxq|dk	r||d<|d	7}|d
}tt|D]}||||<qd
|}||kr|||q|g||<q||fS)aRead 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".
    r#Nz\

rr/)	readlinestrip	parselinerrangelenjoinlowerappend)	rrrlineZnextlinerfieldstypesjrrrrGs4	
rc
Csg}dt|}}||kr>t|||\}}|||d}qt|dkrNdS|d|d|dd}}}d|i}|D]V}|d}|dkr|}d}	n$|d|}||dd}	||krqz|	||<qz||fS)	zParse 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.
    rrrNNNview=r")r*
parsefieldr-findr')
r.r/infieldrr3restZfkeyZfvaluerrrr(ps*

 

r(cCsP|}||kr<||}|dkr q<q|dkr2|d}q|d}q||||fS)z/Separate one key-value pair in a mailcap entry.;\rr)r')r.r7r8startcrrrr5s

r5r3z	/dev/nullc	Csbt|||}|D]L}d|kr@t|d||}|r@t|dkr@qt|||||}||fSdS)aFind 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.

    testrr2)lookupsubstrsystem)	rMIMEtyperfilenameplistentrieser?commandrrrrs	cslg}||kr|||}|d}|dd}||krB|||}dk	r\fdd|D}t|td}|S)Nr%rz/*csg|]}|kr|qSrr).0rGrrr
<listcomp>szlookup.<locals>.<listcomp>rJ)rsortedr	)rrCrrFZ	MIMEtypesrrJrr@s
r@c
Csd}dt|}}||kr||}|d}|dkr^|dkrT|||d}|d}||}q||}|d}|dkr||}q|dkr||}q|dkr||}q|dkr|}||kr||d	kr|d}q|||}	|d}|t|	|}q|d|}q|S)
Nr"rr%r<st{})r*	findparam)
r9rCrDrEresr7r8r>r=namerrrrAs6





rAcCsF|d}t|}|D](}|d||kr||dSqdS)Nr4r")r,r*)rTrEr8prrrrRsrRc	Csddl}t}|jdds(t|dStdt|jdD]}|j||d}t|dkrjtddS|d}|d}t||d|\}}|stdtq:td|t	
|}|r:td|q:dS)	Nrrrz"usage: mailcap [MIMEtype file] ...r3zNo viewer found forz
Executing:zExit status:)sysrargvshowr)r*printrtyperrB)	rVrr7argsrCfilerHrGstsrrrr?s&

r?cCstdtD]}td|qt|s0t}tdtt|}|D]H}t|||}|D].}t|}|D]}td|||qrtqbqJdS)NzMailcap files:	zMailcap entries:z  %-15s)rYrrrL)rfnZckeysrZrFrGkeyskrrrrXs"
rX__main__)N)__doc__rr__all__r	rrr rr(r5rr@rArRr?rX__name__rrrr<module>s$
)

 

Zerion Mini Shell 1.0