łň
\Kc           @   st  d  Z  d d d d g Z d d k Z d Z d Z d	 Z d
 d d d d d d d d d d d d d d d d d d d d d d d  g Z d! d" d# d$ d% d& d' g Z h  d( d) <d( d* <d( d+ <d( d, <d- d. <d/ d0 <d1 d2 <d- d3 <d4 d5 <d1 d6 <d7 d8 <d4 d9 <d: d; <d7 d< <Z d=   Z	 d>   Z
 d?   Z d@   Z dA f  dB     YZ dC e f dD     YZ d S(E   sc   Email address parsing code.

Lifted directly from rfc822.py.  This should eventually be rewritten.
t	   mktime_tzt	   parsedatet   parsedate_tzt   quotei˙˙˙˙Nt    t    s   , t   jant   febt   mart   aprt   mayt   junt   jult   augt   sept   octt   novt   dect   januaryt   februaryt   marcht   aprilt   junet   julyt   augustt	   septembert   octobert   novembert   decembert   mont   tuet   wedt   thut   frit   satt   suni    t   UTt   UTCt   GMTt   Zipţ˙˙t   ASTiÔţ˙˙t   ADTiţ˙˙t   ESTt   EDTi¨ý˙˙t   CSTt   CDTiDý˙˙t   MSTt   MDTiŕü˙˙t   PSTt   PDTc         C   s  |  i    }  |  d i d  p |  d i   t j o |  d =n; |  d i d  } | d j o |  d | d |  d <n t |   d j o< |  d i  d  } t |  d j o | |  d }  qË n t |   d j oW |  d } | i d  } | d j o  | |  | | d g |  d )q5|  i d  n t |   d	 j  o d Sn |  d	  }  |  \ } } } } } | i   } | t	 j o, | | i   } } | t	 j o d Sq´n t	 i
 |  d } | d
 j o | d
 8} n | d d j o | d  } n | i d  } | d j o | | } } n | d d j o | d  } n | d i   p | | } } n | d d j o | d  } n | i  d  } t |  d j o | \ }	 }
 d } n+ t |  d j o | \ }	 }
 } n d Sy@ t |  } t |  } t |	  }	 t |
  }
 t |  } Wn t j
 o d Sn Xd } | i   } t i |  o t | } n' y t |  } Wn t j
 o n X| oF | d j  o d } | } n d } | | d d | d d } n | | | |	 |
 | d d d | f
 S(   sQ   Convert a date string to a time tuple.

    Accounts for military timezones.
    i    t   ,i   i   t   -i   t   +R   i   i   i˙˙˙˙t   :i   t   0id   i  i<   N(   t   splitt   endswitht   lowert	   _daynamest   rfindt   lent   findt   appendt   Nonet   _monthnamest   indext   isdigitt   intt
   ValueErrort   uppert
   _timezonest   has_key(   t   datat   it   stufft   st   ddt   mmt   yyt   tmt   tzt   thht   tmmt   tsst   tzoffsett   tzsign(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR   -   s    +
 

	"c         C   s0   t  |   } t | t  o | d  Sn | Sd S(   s&   Convert a time string to a time tuple.i	   N(   R   t
   isinstancet   tuple(   RH   t   t(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR      s    c         C   sX   |  d d j o t i |  d  d  Sn+ t i |  d  d  } | |  d t i Sd S(   sC   Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp.i	   i   i˙˙˙˙i    N(   i˙˙˙˙(   i    (   R?   t   timet   mktimet   timezone(   RH   RX   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR       s    c         C   s   |  i  d d  i  d d  S(   s   Add quotes around a string.s   \s   \\t   "s   \"(   t   replace(   t   str(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR      s    t   AddrlistClassc           B   s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 e
 d  Z d	   Z d
   Z d   Z d d  Z d   Z RS(   sţ   Address parser class by Ben Escoto.

    To understand what this class does, it helps to have a copy of RFC 2822 in
    front of you.

    Note: this class interface is deprecated and may be removed in the future.
    Use rfc822.AddressList instead.
    c         C   s   d |  _  d |  _ d |  _ d |  _ |  i |  i |  _ |  i  |  i |  i |  _ |  i i d d  |  _ | |  _ g  |  _	 d S(   s   Initialize a new instance.

        `field' is an unparsed address header field, containing
        one or more addresses.
        s   ()<>@,:;."[]i    s    	s   
t   .R   N(
   t   specialst   post   LWSt   CRt   FWSt   atomendsR]   t
   phraseendst   fieldt   commentlist(   t   selfRh   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   __init__Ľ   s    					c         C   s   x |  i  t |  i  j  og |  i |  i  |  i d j o |  i  d 7_  q |  i |  i  d j o |  i i |  i    q Pq Wd S(   s*   Parse up to the start of the next address.s   
i   t   (N(   Rb   R<   Rh   Rc   Ri   R>   t
   getcomment(   Rj   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   gotonext¸   s     c         C   sY   g  } xL |  i  t |  i  j  o2 |  i   } | o | | 7} q	 | i d  q	 W| S(   sV   Parse all addresses.

        Returns a list containing all of the addresses.
        R   (   R   R   (   Rb   R<   Rh   t
   getaddressR>   (   Rj   t   resultt   ad(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   getaddrlistÂ   s     c         C   sś  g  |  _  |  i   |  i } |  i  } |  i   } |  i   g  } |  i t |  i  j o. | o# t i |  i   | d f g } qenŢ|  i |  i d j o= | |  _ | |  _  |  i   } t i |  i   | f g } n|  i |  i d j o g  } t |  i  } |  i d 7_ xK|  i t |  i  j  oY |  i   |  i | j  o+ |  i |  i d j o |  i d 7_ Pn | |  i	   } qWnŐ |  i |  i d j of |  i
   } |  i  o4 t i |  d d i |  i   d	 | f g } qet i |  | f g } nX | o# t i |  i   | d f g } n. |  i |  i |  i j o |  i d 7_ n |  i   |  i t |  i  j  o* |  i |  i d
 j o |  i d 7_ n | S(   s   Parse the next address.i    s   .@R5   i   t   ;t   <s    (R   t   )R2   (   Ri   Rn   Rb   t   getphraselistR<   Rh   t   SPACEt   joint   getaddrspecRo   t   getrouteaddrRa   (   Rj   t   oldpost   oldclt   plistt
   returnlistt   addrspect   fieldlent	   routeaddr(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyRo   Đ   sN    	
		
'		 
'
4#
0c         C   s/  |  i  |  i d j o d Sn t } |  i d 7_ |  i   d } xä |  i t |  i   j  oĘ | o |  i   t } n˘ |  i  |  i d j o |  i d 7_ Pnw |  i  |  i d j o |  i d 7_ t } nG |  i  |  i d j o |  i d 7_ n |  i   } |  i d 7_ P|  i   qG W| S(   s   Parse a route address (Return-path value).

        This method just skips all the route stuff and returns the addrspec.
        Rt   Ni   R   t   >t   @R5   (   Rh   Rb   t   FalseRn   R<   t	   getdomaint   TrueRy   (   Rj   t   expectroutet   adlist(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyRz     s0    
 


c         C   sT  g  } |  i    xĂ |  i t |  i  j  oŠ |  i |  i d j o  | i d  |  i d 7_ ne |  i |  i d j o | i d |  i    n3 |  i |  i |  i j o Pn | i |  i    |  i    q W|  i t |  i  j p |  i |  i d j o t i	 |  Sn | i d  |  i d 7_ |  i    t i	 |  |  i
   S(   s   Parse an RFC 2822 addr-spec.R`   i   R\   s   "%s"R   (   Rn   Rb   R<   Rh   R>   t   getquoteRf   t   getatomt   EMPTYSTRINGRx   R   (   Rj   t   aslist(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyRy   +  s&    
 0
c         C   s)  g  } x|  i  t |  i  j  oů |  i |  i  |  i j o |  i  d 7_  q	 |  i |  i  d j o |  i i |  i    q	 |  i |  i  d j o | i |  i    q	 |  i |  i  d j o  |  i  d 7_  | i d  q	 |  i |  i  |  i j o Pq	 | i |  i	    q	 Wt
 i |  S(   s-   Get the complete domain name from an address.i   Rl   t   [R`   (   Rb   R<   Rh   Rc   Ri   R>   Rm   t   getdomainliteralRf   R   R   Rx   (   Rj   t   sdlist(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR   D  s      c         C   s=  |  i  |  i | j o d Sn d g } t } |  i d 7_ xđ |  i t |  i   j  oÖ | o! | i |  i  |  i  t } n |  i  |  i | j o |  i d 7_ Pnq | o1 |  i  |  i d j o | i |  i    q@ n9 |  i  |  i d j o
 t } n | i |  i  |  i  |  i d 7_ q@ Wt i |  S(   sć  Parse a header fragment delimited by special characters.

        `beginchar' is the start character for the fragment.
        If self is not looking at an instance of `beginchar' then
        getdelimited returns the empty string.

        `endchars' is a sequence of allowable end-delimiting characters.
        Parsing stops when one of these is encountered.

        If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed
        within the parsed fragment.
        R   i   Rl   s   \(	   Rh   Rb   R   R<   R>   Rm   R   R   Rx   (   Rj   t	   beginchart   endcharst   allowcommentst   slistR   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   getdelimitedW  s*    	 

c         C   s   |  i  d d t  S(   s1   Get a quote-delimited fragment from self's field.R\   s   "(   R   R   (   Rj   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR   |  s    c         C   s   |  i  d d t  S(   s7   Get a parenthesis-delimited fragment from self's field.Rl   s   )(   R   R   (   Rj   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyRm     s    c         C   s   d |  i  d d t  S(   s!   Parse an RFC 2822 domain-literal.s   [%s]R   s   ](   R   R   (   Rj   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR     s    c         C   s   d g } | d j o |  i } n x` |  i t |  i  j  oF |  i |  i | j o Pn | i |  i |  i  |  i d 7_ q& Wt i |  S(   s  Parse an RFC 2822 atom.

        Optional atomends specifies a different set of end token delimiters
        (the default is to use self.atomends).  This is used e.g. in
        getphraselist() since phrase endings must not include the `.' (which
        is legal in phrases).R   i   N(   R?   Rf   Rb   R<   Rh   R>   R   Rx   (   Rj   Rf   t   atomlist(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR     s    	 c         C   sď   g  } xâ |  i  t |  i  j  oČ |  i |  i  |  i j o |  i  d 7_  q	 |  i |  i  d j o | i |  i    q	 |  i |  i  d j o |  i i |  i    q	 |  i |  i  |  i j o Pq	 | i |  i	 |  i   q	 W| S(   sý   Parse a sequence of RFC 2822 phrases.

        A phrase is a sequence of words, which are in turn either RFC 2822
        atoms or quoted-strings.  Phrases are canonicalized by squeezing all
        runs of continuous whitespace into one space.
        i   R\   Rl   (
   Rb   R<   Rh   Re   R>   R   Ri   Rm   Rg   R   (   Rj   R}   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyRv     s     N(   t   __name__t
   __module__t   __doc__Rk   Rn   Rr   Ro   Rz   Ry   R   R   R   R   Rm   R   R?   R   Rv   (    (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR_      s   		
		;	 		%			t   AddressListc           B   sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   s@   An AddressList encapsulates a list of parsed RFC 2822 addresses.c         C   s7   t  i |  |  | o |  i   |  _ n
 g  |  _ d  S(   N(   R_   Rk   Rr   t   addresslist(   Rj   Rh   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyRk   ľ  s    c         C   s   t  |  i  S(   N(   R<   R   (   Rj   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   __len__ź  s    c         C   sU   t  d   } |  i | _ x5 | i D]* } | |  i j o | i i |  q# q# W| S(   N(   R   R?   R   R>   (   Rj   t   othert   newaddrt   x(    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   __add__ż  s    
 c         C   s<   x5 | i  D]* } | |  i  j o |  i  i |  q
 q
 W|  S(   N(   R   R>   (   Rj   R   R   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   __iadd__Č  s
    
 c         C   sH   t  d   } x5 |  i D]* } | | i j o | i i |  q q W| S(   N(   R   R?   R   R>   (   Rj   R   R   R   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   __sub__Ď  s    
 c         C   s<   x5 | i  D]* } | |  i  j o |  i  i |  q
 q
 W|  S(   N(   R   t   remove(   Rj   R   R   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   __isub__×  s
    
 c         C   s   |  i  | S(   N(   R   (   Rj   RA   (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyt   __getitem__Ţ  s    (
   R   R   R   Rk   R   R   R    RĄ   RŁ   R¤   (    (    (    s&   /usr/lib/python2.5/email/_parseaddr.pyR   ł  s   							(   R   t   __all__RY   Rw   R   t
   COMMASPACER@   R:   RF   R   R   R    R   R_   R   (    (    (    s&   /usr/lib/python2.5/email/_parseaddr.pys   <module>   s4   	(	V			
	˙ 