-í
ç¶<c       sÜ     d  Z    d k Z  d d g Z 	 d „  Z " d „  Z 5 d „  Z [ d „  Z z d „  Z Š d	 d
 g  d „ Z ž e	 d „ Z
 ª g  d „ Z Ê d „  Z Õ d „  Z ë d „  Z þ e d j o ÿ e ƒ  n d S(   s%   Mailcap file handling.  See RFC 1524.Ns   getcapss	   findmatchc     sç   	   h  }  xÇ t ƒ  D ]¹ }   y  t |  d ƒ } Wn  t j
 o  q n X t | ƒ }  | i ƒ   xY | i	 ƒ  D ]H }  | i | ƒ o  | | | | <n  | | | | | | <q‰ Wq W  | Sd 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".

    s   rN(   s   capss   listmailcapfiless   mailcaps   opens   fps   IOErrors   readmailcapfiles   morecapss   closes   keyss   keys   has_key(   s   mailcaps   fps   morecapss   keys   caps(    (    s   /usr/lib/python2.2/mailcap.pys   getcaps	 s    		 	 	!c     s™   " # % t  i i d ƒ o& & t  i d } ' | i d ƒ } nM ) t  i i d ƒ o * t  i d }  n
 - d }  . |  d d d d g } 0 | Sd	 S(
   s7   Return a list of all mailcap files found on the system.s   MAILCAPSs   :s   HOMEs   .s	   /.mailcaps   /etc/mailcaps   /usr/etc/mailcaps   /usr/local/etc/mailcapN(   s   oss   environs   has_keys   strs   splits   mailcapss   home(   s   homes   mailcapss   str(    (    s   /usr/lib/python2.2/mailcap.pys   listmailcapfiles" s   	c    s²  5 = > h  } ? x’? d o‡@ |  i ƒ  } A | o A Pn C | d d j p | i ƒ  d j o
 D q n E | } G xQ G | d d j o< H |  i ƒ  } I | o I d } n J | d  | } q WL t | ƒ \ } } M | o | o
 N q n P | i	 d ƒ } Q x4 t t | ƒ ƒ DQ ] } R | | i ƒ  | | <q+WS d i | ƒ i ƒ  } U | i | ƒ o V | | i | ƒ n X | g | | <q WY | Sd	 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   i    s   #s    iþÿÿÿs   \
s   
s   /N(   s   capss   fps   readlines   lines   strips   nextlines	   parselines   keys   fieldss   splits   typess   ranges   lens   js   joins   lowers   has_keys   append(   s   fps   nextlines   keys   fieldss   js   capss   lines   types(    (    s   /usr/lib/python2.2/mailcap.pys   readmailcapfile5 s8   	 
 '
	  
 	c 
   sŽ  [ ` a g  } b d t |  ƒ f \ } } c xM c | | j  o< d t |  | | ƒ \ } } e | i | ƒ f | d } q0 Wg t | ƒ d j  o h t t f Sn i | d | d | d f \ } }	 } j h  |	 d <} k xš | Dk ] } l | i d ƒ } m | d j  o n | } o d } n+ q | |  i ƒ  } r | | d i ƒ  } s | i | ƒ o u n w | | | <qç Wx | | f Sd 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   s   views   =s    N(   s   fieldss   lens   lines   is   ns
   parsefields   fields   appends   Nones   keys   views   rests   finds   fkeys   fvalues   strips   has_key(
   s   lines   is   fieldss   rests   ns   fields   keys   fkeys   fvalues   view(    (    s   /usr/lib/python2.2/mailcap.pys	   parseline[ s0   	 '
 		c    s›   z { | | } } xh } | | j  oW ~ |  | }  | d j o € Pn/  | d j o ‚ | d } n „ | d } q W… |  | | !i ƒ  | f Sd S(   s/   Separate one key-value pair in a mailcap entry.s   ;s   \i   i   N(   s   is   starts   ns   lines   cs   strip(   s   lines   is   ns   starts   c(    (    s   /usr/lib/python2.2/mailcap.pys
   parsefieldz s   	 s   views	   /dev/nullc 	   sÆ   Š ’ “ t  |  | | ƒ } • x” | D• ]‰ } – | i d ƒ oG — t | d | | ƒ } ˜ | o t i | ƒ d j o
 ™ q% n n š t | | | | | ƒ } › | | f Sq% Wœ t t f Sd 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.

    s   testi    N(   s   lookups   capss   MIMEtypes   keys   entriess   es   has_keys   substs   filenames   plists   tests   oss   systems   commands   None(	   s   capss   MIMEtypes   keys   filenames   plists   es   entriess   tests   command(    (    s   /usr/lib/python2.2/mailcap.pys	   findmatchŠ s   
 	 c    s¶   ž Ÿ g  }   |  i | ƒ o ¡ | |  | } n ¢ | i d ƒ } £ | d d } ¤ |  i | ƒ o ¥ | |  | } n ¦ | t j	 o § t | d „ | ƒ } n ¨ | Sd  S(   Ns   /i    s   /*c    s   § |  i | ƒ S(   N(   s   es   has_keys   key(   s   es   key(    (    s   /usr/lib/python2.2/mailcap.pys   <lambda>§ s    (	   s   entriess   capss   has_keys   MIMEtypes   splits	   MIMEtypess   keys   Nones   filter(   s   capss   MIMEtypes   keys	   MIMEtypess   entries(    (    s   /usr/lib/python2.2/mailcap.pys   lookupž s   	c 
   sË  ª ¬ d } ­ d t |  ƒ f \ } }	 ® x“® | |	 j  o‚¯ |  | } | d } ° | d j oC ± | d j o" ² |  | | d !} | d } n ³ | | } nµ |  | } | d } ¶ | d j o · | | } nÝ ¸ | d j o ¹ | | } n¼ º | d j o » | | } n› ¼ | d j oy ½ | } ¾ x3 ¾ | |	 j  o |  | d	 j o ¿ | d } q@WÀ |  | | !} Á | d } Â | t
 | | ƒ } n Ç | d | } q- WÈ | Sd  S(
   Ns    i    i   s   %s   \s   ss   ts   {s   }(   s   ress   lens   fields   is   ns   cs   filenames   MIMEtypes   starts   names	   findparams   plist(
   s   fields   MIMEtypes   filenames   plists   cs   names   starts   is   ress   n(    (    s   /usr/lib/python2.2/mailcap.pys   substª s4   	 "	 !c    sp   Ê Ë |  i ƒ  d }  Ì t |  ƒ } Í x: | DÍ ]/ } Î | |  i ƒ  |  j o Ï | | Sn q/ WÐ d Sd  S(   Ns   =s    (   s   names   lowers   lens   ns   plists   p(   s   names   plists   ps   n(    (    s   /usr/lib/python2.2/mailcap.pys	   findparamÊ s   
 	c  	   s@  Õ Ö d  k  } × t ƒ  } Ø | i d o Ù t | ƒ Ú d  Sn Û xñ t d t | i ƒ d ƒ DÛ ]Ñ } Ü | i | | d !} Ý t | ƒ d j  o Þ d GHß d  Sn à | d }  á | d } â t | |  d | ƒ \ } } ã | o ä d Gt GHn9 æ d G| GHç t i | ƒ } è | o é d G| GHn qd Wd  S(	   Ni   i   s"   usage: mailcap [MIMEtype file] ...i    s   views   No viewer found fors
   Executing:s   Exit status:(   s   syss   getcapss   capss   argvs   shows   ranges   lens   is   argss   MIMEtypes   files	   findmatchs   commands   es   types   oss   systems   sts(	   s   MIMEtypes   es   is   argss   capss   syss   commands   files   sts(    (    s   /usr/lib/python2.2/mailcap.pys   testÕ s(    	
c    s
  ë ì d GHí x  t  ƒ  Dí ] } í d | GHq Wî Hï |  o ï t ƒ  }  n ð d GHñ Hò |  i ƒ  } ó | i ƒ  ô xˆ | Dô ]} } õ | GHö |  | } ÷ x\ | D÷ ]Q } ø | i ƒ  } ù | i ƒ  ú x% | Dú ] } û d | G| | GHqÙ Wü Hqª Wq‚ Wd  S(   Ns   Mailcap files:s   	s   Mailcap entries:s     %-15s(   s   listmailcapfiless   fns   capss   getcapss   keyss   ckeyss   sorts   types   entriess   es   k(   s   capss   es   ckeyss   entriess   keyss   types   ks   fn(    (    s   /usr/lib/python2.2/mailcap.pys   showë s.    	  
 	
 	
 	s   __main__(   s   __doc__s   oss   __all__s   getcapss   listmailcapfiless   readmailcapfiles	   parselines
   parsefields	   findmatchs   Nones   lookups   substs	   findparams   tests   shows   __name__(   s
   parsefields   __all__s	   findparams   listmailcapfiless   shows   substs	   findmatchs   getcapss   readmailcapfiles   lookups	   parselines   tests   os(    (    s   /usr/lib/python2.2/mailcap.pys   ? s   & 