£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>

V~gc           @   s   d  Z  d d l Z d d g Z d   Z d   Z d   Z d   Z d	   Z d
 d g  d  Z d d  Z
 g  d  Z d   Z d   Z d   Z e d k r e   n  d S(   s%   Mailcap file handling.  See RFC 1524.iNt   getcapst	   findmatchc          C   s   i  }  x t    D] } y t | d  } Wn t k
 r? q n X|  t |  } Wd QXxE | j   D]7 \ } } | |  k r | |  | <qf |  | | |  | <qf Wq W|  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".

    t   rN(   t   listmailcapfilest   opent   IOErrort   readmailcapfilet	   iteritems(   t   capst   mailcapt   fpt   morecapst   keyt   value(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyR    	   s    
c          C   sm   d t  j k r. t  j d }  |  j d  } n; d t  j k rM t  j d } n d } | d d d d g } | S(	   s7   Return a list of all mailcap files found on the system.t   MAILCAPSt   :t   HOMEt   .s	   /.mailcaps   /etc/mailcaps   /usr/etc/mailcaps   /usr/local/etc/mailcap(   t   ost   environt   split(   t   strt   mailcapst   home(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyR   "   s    
c         C   s;  i  } x.|  j    } | s Pn  | d d k s	 | j   d k rG q	 n  | } x= | d d k r |  j    } | s{ d } n  | d  | } qP Wt |  \ } } | o | s q	 n  | j d  } x. t t |   D] } | | j   | | <q Wd j |  j   } | | k r&| | j |  q	 | g | | <q	 W| 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".
    i    t   #t    is   \
s   
t   /(	   t   readlinet   stript	   parselineR   t   ranget   lent   joint   lowert   append(   R
   R   t   linet   nextlineR   t   fieldst   typest   j(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyR   5   s0    	 " 	c   
      C   s   g  } d t  |   } } x? | | k  rZ t |  | |  \ } } | j |  | d } q Wt  |  d k  rq d S| d | d | d } } } i | d 6} xu | D]m } | j d  } | d k  r | } d }	 n$ | |  j   } | | d j   }	 | | k rq |	 | | <q W| | f S(	   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.
    i    i   i   t   viewt   =R   N(   NN(   R   t
   parsefieldR"   t   Nonet   findR   (
   R#   R%   t   it   nt   fieldR   R(   t   restt   fkeyt   fvalue(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyR   [   s*     	c         C   sm   | } xM | | k  rU |  | } | d k r/ Pq	 | d k rH | d } q	 | d } q	 W|  | | !j    | f S(   s/   Separate one key-value pair in a mailcap entry.t   ;s   \i   i   (   R   (   R#   R-   R.   t   startt   c(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyR*   z   s    
R(   s	   /dev/nullc   	      C   s   t  |  | |  } xt | D]l } d | k re t | d | |  } | re t j |  d k re q qe n  t | | | | |  } | | f SWd S(   s  Find 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.

    t   testi    N(   NN(   t   lookupt   substR   t   systemR+   (	   R   t   MIMEtypeR   t   filenamet   plistt   entriest   eR6   t   command(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyR      s    		c         C   s   g  } | |  k r# | |  | } n  | j  d  } | d d } | |  k r] | |  | } n  | d  k	 r t | d  |  } n  | S(   NR   i    s   /*c         S   s
   | |  k S(   N(    (   R>   R   (    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyt   <lambda>   R   (   R   R+   t   filter(   R   R:   R   R=   t	   MIMEtypes(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyR7      s    c   
      C   s`  d } d t  |   } } x@| | k  r[|  | } | d } | d k r | d k rr |  | | d !} | d } n  | | } q |  | } | d } | d k r | | } q | d k r | | } q | d k r | | } q | d k rJ| } x* | | k  r|  | d	 k r| d } q W|  | | !}	 | d } | t |	 |  } q | d | } q W| S(
   NR   i    i   t   %s   \t   st   tt   {t   }(   R   t	   findparam(
   R/   R:   R;   R<   t   resR-   R.   R5   R4   t   name(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyR8      s6    
 
 
 

c         C   sO   |  j    d }  t |   } x, | D]$ } | |  j    |  k r# | | Sq# Wd S(   NR)   R   (   R!   R   (   RJ   R<   R.   t   p(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyRH      s    c    	      C   s   d d  l  }  t   } |  j d s0 t |  d  Sx t d t |  j  d  D] } |  j | | d !} t |  d k  r d GHd  S| d } | d } t | | d |  \ } } | s d Gt GHqL d G| GHt j	 |  } | rL d	 G| GHqL qL Wd  S(
   Nii   i   s"   usage: mailcap [MIMEtype file] ...i    R(   s   No viewer found fors
   Executing:s   Exit status:(
   t   sysR    t   argvt   showR   R   R   t   typeR   R9   (	   RL   R   R-   t   argsR:   t   fileR?   R>   t   sts(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyR6      s&    	
"

	c         C   s   d GHx t    D] } d | GHq WH|  s5 t   }  n  d GHH|  j   } | j   xg | D]_ } | GH|  | } xG | D]? } | j   } | j   x | D] } d | G| | GHq WHqt WqX Wd  S(   Ns   Mailcap files:s   	s   Mailcap entries:s     %-15s(   R   R    t   keyst   sort(   R   t   fnt   ckeysRO   R=   R>   RS   t   k(    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyRN      s&      


t   __main__(   t   __doc__R   t   __all__R    R   R   R   R*   R   R+   R7   R8   RH   R6   RN   t   __name__(    (    (    s,   /opt/alt/python27/lib64/python2.7/mailcap.pyt   <module>   s   			&		 			