Ñò
mÈKc           @   sÕ  d  Z  d d k Z d d k Z d d k Z d d k l Z l Z e ƒ  i i ƒ  z. e i	 o e d d e
 ƒ n d d k Z Wd QXd d k l Z e d d d	 ƒd
 d d d d d g Z d
 e i f d „  ƒ  YZ y d d k Z Wn e j
 o d d k Z n Xe i ƒ  Z [ d a d „  Z d a d „  Z d „  Z d „  Z d Z h e d 6e d 6e d 6e d 6d d 6d d 6Z h d d 6d d 6d d 6d d 6d  d 6d! d 6Z d" „  Z d# „  Z d$ „  Z  d% „  Z! d S(&   s<   Various tools used by MIME-reading or MIME-writing programs.iÿÿÿÿN(   t   filterwarningst   catch_warningst   ignores   .*rfc822 has been removed(   t   warnpy3ks@   in 3.x, mimetools has been removed in favor of the email packaget
   stackleveli   t   Messaget   choose_boundaryt   encodet   decodet   copyliteralt
   copybinaryc           B   sk   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z RS(   sˆ   A derived class of rfc822.Message that knows about MIME headers and
    contains some hooks for decoding encoded and multipart messages.i   c         C   sR   t  i i |  | | ƒ |  i d ƒ |  _ |  i d ƒ |  _ |  i ƒ  |  i ƒ  d  S(   Ns   content-transfer-encodings   content-type(   t   rfc822R   t   __init__t	   getheadert   encodingheadert
   typeheadert	   parsetypet
   parseplist(   t   selft   fpt   seekable(    (    s   /usr/lib/python2.6/mimetools.pyR      s
    
c         C   sß   |  i  } | d  j o
 d } n d | j o* | i d ƒ } | | |  _ | |  } n
 d |  _ | i d ƒ } x4 t t | ƒ ƒ D]  } | | i ƒ  i ƒ  | | <q‚ Wd i	 | ƒ |  _
 | d |  _ d i	 | d ƒ |  _ d  S(   Ns
   text/plaint   ;t    t   /i    i   (   R   t   Nonet   indext	   plisttextt   splitt   ranget   lent   stript   lowert   joint   typet   maintypet   subtype(   R   t   strt   it   fields(    (    s   /usr/lib/python2.6/mimetools.pyR   !   s    	
	 c         C   sÛ   |  i  } g  |  _ xÂ | d  d j o° | d } d | j o | i d ƒ } n t | ƒ } | |  } d | j o? | i d ƒ } | |  i ƒ  i ƒ  d | | d i ƒ  } n |  i i | i ƒ  ƒ | | } q Wd  S(   Ni   R   t   =(   R   t   plistR   R   R   R   t   append(   R   R$   t   endt   fR%   (    (    s   /usr/lib/python2.6/mimetools.pyR   2   s    		 

0c         C   s   |  i  S(   N(   R(   (   R   (    (    s   /usr/lib/python2.6/mimetools.pyt   getplistD   s    c         C   sW   | i  ƒ  d } t | ƒ } x4 |  i D]) } | |  | j o t i | | ƒ Sq& Wd  S(   NR'   (   R   R   R(   R   t   unquoteR   (   R   t   namet   nt   p(    (    s   /usr/lib/python2.6/mimetools.pyt   getparamG   s    
 c         C   sU   g  } xH |  i  D]= } | i d ƒ } | d j o | i | |  i ƒ  ƒ q q W| S(   NR'   i    (   R(   t   findR)   R   (   R   t   resultR0   R%   (    (    s   /usr/lib/python2.6/mimetools.pyt   getparamnamesO   s    
 c         C   s"   |  i  d  j o d S|  i  i ƒ  S(   Nt   7bit(   R   R   R   (   R   (    (    s   /usr/lib/python2.6/mimetools.pyt   getencodingW   s    c         C   s   |  i  S(   N(   R!   (   R   (    (    s   /usr/lib/python2.6/mimetools.pyt   gettype\   s    c         C   s   |  i  S(   N(   R"   (   R   (    (    s   /usr/lib/python2.6/mimetools.pyt   getmaintype_   s    c         C   s   |  i  S(   N(   R#   (   R   (    (    s   /usr/lib/python2.6/mimetools.pyt
   getsubtypeb   s    (   t   __name__t
   __module__t   __doc__R   R   R   R,   R1   R4   R6   R7   R8   R9   (    (    (    s   /usr/lib/python2.6/mimetools.pyR      s   									i    c          C   s(   t  i ƒ  t d 7a t }  t  i ƒ  |  S(   Ni   (   t   _counter_lockt   acquiret   _countert   release(   R3   (    (    s   /usr/lib/python2.6/mimetools.pyt   _get_next_counters   s
    


c          C   sõ   d d k  }  t d j oÂ d d k } y | i | i ƒ  ƒ } Wn | i j
 o d } n Xy t t i	 ƒ  ƒ } Wn t
 j
 o d } n Xy t t i ƒ  ƒ } Wn t
 j
 o d } n X| d | d | a n d t |  i  ƒ  t ƒ  f S(   sx  Return a string usable as a multipart boundary.

    The string chosen is unique within a single program run, and
    incorporates the user id (if available), process id (if available),
    and current time.  So it's very unlikely the returned string appears
    in message text, but there's no guarantee.

    The boundary contains dots so you have to quote it in the header.iÿÿÿÿNs	   127.0.0.1t   1t   .s
   %s.%.3f.%d(   t   timet   _prefixR   t   sockett   gethostbynamet   gethostnamet   gaierrort   reprt   ost   getuidt   AttributeErrort   getpidRA   (   RD   RF   t   hostidt   uidt   pid(    (    s   /usr/lib/python2.6/mimetools.pyR   }   s"    c         C   sÕ   | d j o d d k  } | i |  | ƒ S| d j o d d k } | i |  | ƒ S| d j o d d k } | i |  | ƒ S| d j o | i |  i ƒ  ƒ S| t j o t |  t | | ƒ n t d | ‚ d S(   sD   Decode common content-transfer-encodings (base64, quopri, uuencode).t   base64iÿÿÿÿNs   quoted-printablet   uuencodes
   x-uuencodet   uues   x-uueR5   t   8bits%   unknown Content-Transfer-Encoding: %s(   RS   s
   x-uuencodeRT   s   x-uue(   s   7bitRU   (	   RR   R   t   quoprit   uut   writet   readt	   decodetabt   pipethrought
   ValueError(   t   inputt   outputt   encodingRR   RV   RW   (    (    s   /usr/lib/python2.6/mimetools.pyR      s    c         C   sØ   | d j o d d k  } | i |  | ƒ S| d j o  d d k } | i |  | d ƒ S| d j o d d k } | i |  | ƒ S| d j o | i |  i ƒ  ƒ S| t j o t |  t | | ƒ n t d | ‚ d S(   sD   Encode common content-transfer-encodings (base64, quopri, uuencode).RR   iÿÿÿÿNs   quoted-printablei    RS   s
   x-uuencodeRT   s   x-uueR5   RU   s%   unknown Content-Transfer-Encoding: %s(   s   uuencodes
   x-uuencodes   uues   x-uue(   s   7bits   8bit(	   RR   R   RV   RW   RX   RY   t	   encodetabR[   R\   (   R]   R^   R_   RR   RV   RW   (    (    s   /usr/lib/python2.6/mimetools.pyR   °   s    sa   (
TEMP=/tmp/@uu.$$
sed "s%^begin [0-7][0-7]* .*%begin 600 $TEMP%" | uudecode
cat $TEMP
rm $TEMP
)RS   s
   x-uuencodeRT   s   x-uues   mmencode -u -qs   quoted-printables   mmencode -u -bRR   s   uuencode tempfiles   mmencode -qs   mmencode -bc         C   s-   t  i | d ƒ } t |  | ƒ | i ƒ  d  S(   Nt   w(   RK   t   popenR	   t   close(   R]   t   commandt   pipe(    (    s   /usr/lib/python2.6/mimetools.pyt   pipetoà   s    c         C   s}   t  i ƒ  \ } } t i | d ƒ } t |  | ƒ | i ƒ  t i | d | d ƒ } t | | ƒ | i ƒ  t i | ƒ d  S(   NRa   s    <t   r(	   t   tempfilet   mkstempRK   t   fdopenR	   Rc   Rb   R
   t   unlink(   R]   Rd   R^   t   fdt   tempnamet   tempRe   (    (    s   /usr/lib/python2.6/mimetools.pyR[   å   s    

c         C   s/   x( |  i  ƒ  } | p Pn | i | ƒ q d  S(   N(   t   readlineRX   (   R]   R^   t   line(    (    s   /usr/lib/python2.6/mimetools.pyR	   ï   s
     c         C   s8   d } x+ |  i  | ƒ } | p Pn | i | ƒ q	 d  S(   Ni    (   RY   RX   (   R]   R^   t   BUFSIZERp   (    (    s   /usr/lib/python2.6/mimetools.pyR
   õ   s     ("   R<   RK   t   sysRh   t   warningsR    R   t   __exit__t	   __enter__t   py3kwarningt   DeprecationWarningR   R   t   __all__R   t   threadt   ImportErrort   dummy_threadt   allocate_lockR=   R?   RA   R   RE   R   R   R   t   uudecode_pipeRZ   R`   Rf   R[   R	   R
   (    (    (    s   /usr/lib/python2.6/mimetools.pyt   <module>   sZ   
		W		 		

		
	