Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
3 \¨ã@s¤dZddlZddlZddgZdd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z ddgfdd„Z d dd„Z gfdd„Z dd„Zdd„Zdd„Zedkr eƒdS)!z%Mailcap file handling. See RFC 1524.éNÚgetcapsÚ findmatchcCsd|krd|dfSdSdS)NÚlinenoré)rr©)Úentryrrú/usr/lib64/python3.6/mailcap.pyÚlineno_sort_key s r cCs˜i}d}xŠtƒD]€}yt|dƒ}Wntk r8wYnX|�t||ƒ\}}WdQRXx6|jƒD]*\}}||kr||||<qb|||||<qbWqW|S)a 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". rÚrN)ÚlistmailcapfilesÚopenÚOSErrorÚ_readmailcapfileÚitems)ÚcapsrZmailcapÚfpZmorecapsÚkeyÚvaluerrrrs   cCsPdtjkr"tjd}|jtjƒ}n*dtjkr8tjd}nd}|ddddg}|S)z7Return a list of all mailcap files found on the system.ZMAILCAPSÚHOMEÚ.z /.mailcapz /etc/mailcapz/usr/etc/mailcapz/usr/local/etc/mailcap)ÚosÚenvironÚsplitÚpathsep)ZpathstrZmailcapsÚhomerrrr -s    r cCs tjdtdƒt|dƒ\}}|S)z?Read a mailcap file and return a dictionary keyed by MIME type.z2readmailcapfile is deprecated, use getcaps insteadéN)ÚwarningsÚwarnÚDeprecationWarningr)rrÚ_rrrÚreadmailcapfile?sr c Csi}xô|jƒ}|sP|ddks|jƒdkr.q|}x4|d d…dkrf|jƒ}|sTd}|dd …|}q4Wt|ƒ\}}|oz|s~q|dk r–||d<|d 7}|jd ƒ}x$tt|ƒƒD]}||jƒ||<q®Wd j|ƒjƒ}||krì||j|ƒq|g||<qW||fS) a�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". rú#ÚrNz\ Ú rrú/éþÿÿÿr%) ÚreadlineÚstripÚ parselinerÚrangeÚlenÚjoinÚlowerÚappend) rrrÚlineZnextlinerÚfieldsÚtypesÚjrrrrGs6   rc Csâg}dt|ƒ}}x.||kr@t|||ƒ\}}|j|ƒ|d}qWt|ƒdkrRdS|d|d|dd…}}}d|i}x^|D]V}|jdƒ}|dkr |}d} n$|d|…jƒ}||dd…jƒ} ||krÎq€| ||<q€W||fS) zÈ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. rrrNÚviewú=r")NN)r*Ú parsefieldr-Úfindr') r.r/ÚiÚnÚfieldrr2ÚrestZfkeyZfvaluerrrr(ps*        r(cCsT|}x:||kr>||}|dkr"Pq|dkr4|d}q|d}qW|||…jƒ|fS)z/Separate one key-value pair in a mailcap entry.ú;ú\rr)r')r.r6r7ÚstartÚcrrrr4�s   r4r2z /dev/nullc Csbt|||ƒ}xP|D]H}d|krBt|d||ƒ}|rBtj|ƒdkrBqt|||||ƒ}||fSWdS)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. ÚtestrN)NN)ÚlookupÚsubstrÚsystem) rÚMIMEtyperÚfilenameÚplistÚentriesÚer>ÚcommandrrrrŸs   cslg}||kr|||}|jdƒ}|dd}||krB|||}ˆdk r\‡fdd„|Dƒ}t|td�}|S)Nr$rz/*csg|]}ˆ|kr|‘qSrr)Ú.0rF)rrrú ¼szlookup..)r)rÚsortedr )rrBrrEZ MIMEtypesr)rrr?³s     r?c Cs d}dt|ƒ}}xô||k�r||}|d}|dkr`|dkrV|||d…}|d}||}q||}|d}|dkr‚||}q|dkr”||}q|dkr¦||}q|dkrø|}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@cCsF|jƒd}t|ƒ}x,|D]$}|d|…jƒ|kr||d…SqWdS)Nr3r")r,r*)rRrDr7ÚprrrrPàs   rPc CsÆddl}tƒ}|jdd…s(t|ƒdSx˜tdt|jƒdƒD]‚}|j||d…}t|ƒdkrjtdƒdS|d}|d}t||d|ƒ\}}|sœtdtƒqës&    r>cCs¨tdƒxtƒD]}td|ƒqWtƒ|s4tƒ}tdƒtƒt|ƒ}xX|D]P}t|ƒ||}x:|D]2}t|ƒ}x|D]}td|||ƒq|WtƒqjWqPWdS)NzMailcap files:ú zMailcap entries:z %-15s)rWr rrJ)rÚfnZckeysrXrErFÚkeysÚkrrrrVs"    rVÚ__main__)N)Ú__doc__rrÚ__all__r rr r rr(r4rr?r@rPr>rVÚ__name__rrrrÚs$ )