???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................ó
™V~gc           @   sÈ   d  Z  d g Z d d l Z d d l m Z d d l m Z e j d ƒ Z e j d ƒ Z e j d ƒ Z	 e j d ƒ Z
 e j d	 ƒ Z d
 Z d Z e ƒ  Z d e f d „  ƒ  YZ d d d „  ƒ  YZ d S(   s  FeedParser - An email feed parser.

The feed parser implements an interface for incrementally parsing an email
message, line by line.  This has advantages for certain applications, such as
those reading email messages off a socket.

FeedParser.feed() is the primary interface for pushing new data into the
parser.  It returns when there's nothing more it can do with the available
data.  When you have no more data to push into the parser, call .close().
This completes the parsing and returns the root message object.

The other advantage of this parser is that it will never raise a parsing
exception.  Instead, when it finds something unexpected, it adds a 'defect' to
the current message.  Defects are just instances that live on the message
object's .defects attribute.
t
   FeedParseriÿÿÿÿN(   t   errors(   t   messages   
||
s   (
||
)s
   (
||
)\Zs(   ^(From |[\041-\071\073-\176]{1,}:|[\t ])t    s   
t   BufferedSubFilec           B   sq   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z RS(   sk  A file-ish object that can have new data loaded into it.

    You can also push and pop line-matching predicates onto a stack.  When the
    current predicate matches the current line, a false EOF response
    (i.e. empty string) is returned instead.  This lets the parser adhere to a
    simple abstraction -- it parses until EOF closes the current message.
    c         C   s(   g  |  _  g  |  _ g  |  _ t |  _ d  S(   N(   t   _partialt   _linest	   _eofstackt   Falset   _closed(   t   self(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   __init__3   s    			c         C   s   |  j  j | ƒ d  S(   N(   R   t   append(   R
   t   pred(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   push_eof_matcher=   s    c         C   s   |  j  j ƒ  S(   N(   R   t   pop(   R
   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   pop_eof_matcher@   s    c         C   s8   |  j  d j |  j ƒ j t ƒ ƒ g  |  _ t |  _ d  S(   NR   (   t	   pushlinest   joinR   t
   splitlinest   TrueR	   (   R
   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   closeC   s    "	c         C   sn   |  j  s |  j r d St S|  j  j ƒ  } x> |  j d  d  d … D]& } | | ƒ r@ |  j  j | ƒ d Sq@ W| S(   NR   iÿÿÿÿ(   R   R	   t   NeedMoreDataR   R   R   (   R
   t   linet   ateof(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   readlineI   s    		c         C   s&   | t  k	 s t ‚ |  j j | ƒ d  S(   N(   R   t   AssertionErrorR   R   (   R
   R   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt
   unreadline[   s    c         C   s¿   | j  t ƒ } | s* | d j d ƒ r= |  j | 7_ d S|  j r† |  j j | d ƒ d j |  j ƒ j  t ƒ | d d +|  j 2n  | d j d ƒ s® | j ƒ  g |  _ n  |  j | ƒ d S(	   s$   Push some new data into this object.i    s   
s   NR   i   iÿÿÿÿ(   s   
s   (   R   R   t   endswithR   R   R   R   R   (   R
   t   datat   parts(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   push`   s    	"
c         C   s   | d  d  d … |  j  d *d  S(   Niÿÿÿÿi    (   R   (   R
   t   lines(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyR   x   s    c         C   s   |  j  S(   N(   R	   (   R
   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt	   is_closed|   s    c         C   s   |  S(   N(    (   R
   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   __iter__   s    c         C   s%   |  j  ƒ  } | d k r! t ‚ n  | S(   NR   (   R   t   StopIteration(   R
   R   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   next‚   s    	(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R   R!   R"   R$   (    (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyR   +   s   	
									c           B   se   e  Z d  Z e j d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z RS(
   s   A feed-style parser of email.c         C   sO   | |  _  t ƒ  |  _ g  |  _ |  j ƒ  j |  _ d |  _ d |  _	 t
 |  _ d S(   s@   _factory is called with no arguments to create a new message objN(   t   _factoryR   t   _inputt	   _msgstackt	   _parsegenR$   t   _parset   Nonet   _curt   _lastR   t   _headersonly(   R
   R(   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyR      s    				c         C   s   t  |  _ d  S(   N(   R   R0   (   R
   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   _set_headersonly˜   s    c         C   s   |  j  j | ƒ |  j ƒ  d S(   s   Push more data into the parser.N(   R)   R   t   _call_parse(   R
   R   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   feed›   s    c         C   s&   y |  j  ƒ  Wn t k
 r! n Xd  S(   N(   R,   R#   (   R
   (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyR2       s    c         C   so   |  j  j ƒ  |  j ƒ  |  j ƒ  } |  j s3 t ‚ | j ƒ  d k rk | j ƒ  rk | j j	 t
 j ƒ  ƒ n  | S(   s<   Parse all remaining data and return the root message object.t	   multipart(   R)   R   R2   t   _pop_messageR*   R   t   get_content_maintypet   is_multipartt   defectsR   R   t!   MultipartInvariantViolationDefect(   R
   t   root(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyR   ¦   s    
c         C   s€   |  j  ƒ  } |  j r: |  j j ƒ  d k r: | j d ƒ n  |  j rZ |  j d j | ƒ n  |  j j | ƒ | |  _ | |  _ d  S(   Ns   multipart/digests   message/rfc822iÿÿÿÿ(   R(   R.   t   get_content_typet   set_default_typeR*   t   attachR   R/   (   R
   t   msg(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   _new_message²   s    		c         C   s8   |  j  j ƒ  } |  j  r+ |  j  d |  _ n	 d  |  _ | S(   Niÿÿÿÿ(   R*   R   R.   R-   (   R
   t   retval(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyR5   ¼   s
    		c         c   s•  |  j  ƒ  g  } xj |  j D]_ } | t k r7 t Vq n  t j | ƒ sl t j | ƒ sh |  j j | ƒ n  Pn  | j | ƒ q W|  j | ƒ |  j	 rg  } xM t
 rè |  j j ƒ  } | t k rÈ t Vqœ n  | d k rØ Pn  | j | ƒ qœ W|  j j t j | ƒ ƒ d  S|  j j ƒ  d k rxí t
 r
|  j j t j ƒ x, |  j ƒ  D] } | t k rat VqDn  PqDW|  j ƒ  } |  j j ƒ  x1 t
 r²|  j j ƒ  } | t k r®t Vq‚n  Pq‚Wx1 t
 ræ|  j j ƒ  } | t k rât Vq¶n  Pq¶W| d k r÷Pn  |  j j | ƒ qWd  S|  j j ƒ  d k rax, |  j ƒ  D] } | t k rNt Vq1n  Pq1W|  j ƒ  d  S|  j j ƒ  d k r:|  j j ƒ  } | d  k r|  j j j t j ƒ  ƒ g  } x5 |  j D]* } | t k r×t Vqºn  | j | ƒ qºW|  j j t j | ƒ ƒ d  Sd | } t j d t j | ƒ d ƒ } t
 }	 g  }
 t } xÃt
 r|  j j ƒ  } | t k rpt VqDn  | d k r€Pn  | j | ƒ } | rê| j d ƒ r·| j d	 ƒ } Pn  |	 r7|
 r|
 d
 } t  j! | ƒ } | r| t" | j d ƒ ƒ  |
 d
 <n  t j |
 ƒ |  j _# n  t }	 |  j j | ƒ qDn  xY t
 r’|  j j ƒ  } | t k rft Vq:n  | j | ƒ } | s:|  j j | ƒ Pq:q:W|  j j | j ƒ x, |  j ƒ  D] } | t k rÐt Vq³n  Pq³W|  j$ j ƒ  d k ra|  j$ j% } | d k rd  |  j$ _% qÄ| d  k	 rÄt  j! | ƒ } | r^t" | j d ƒ ƒ } | |  |  j$ _% q^qÄnc |  j$ j& ƒ  } t' | t( ƒ rÄt  j! | ƒ } | rÄ| t" | j d ƒ ƒ  } |  j$ j | ƒ qÄn  |  j j ƒ  |  j ƒ  |  j |  _$ qD|	 söt) ‚ |
 j | ƒ qDW|	 r‰|  j j j t j* ƒ  ƒ |  j j t j |
 ƒ ƒ g  } x( |  j D] } | t k rOt VqOqOqOWt j | ƒ |  j _% d  S| r›d g } n g  } x5 |  j D]* } | t k rÈt Vq«n  | j | ƒ q«W| r!| d } t+ j | ƒ } | r!| t" | j d ƒ ƒ | d <q!n  t j | ƒ |  j _% d  Sg  } x5 |  j D]* } | t k rgt VqJn  | j | ƒ qJW|  j j t j | ƒ ƒ d  S(   NR   s   message/delivery-statusR   R4   s   --s   (?P<sep>s4   )(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$t   endt   linesepiÿÿÿÿi    (,   R?   R)   R   t   headerREt   matcht   NLCRER   R   t   _parse_headersR0   R   R   R.   t   set_payloadt   EMPTYSTRINGR   R;   R   R+   R5   R   R6   t   get_boundaryR-   R8   R   t   NoBoundaryInMultipartDefectt   ret   compilet   escapeR   t   groupt	   NLCRE_eolt   searcht   lent   preambleR/   t   epiloguet   get_payloadt
   isinstancet
   basestringR   t   StartBoundaryNotFoundDefectt	   NLCRE_bol(   R
   t   headersR   R    R@   R>   t   boundaryt	   separatort
   boundaryret   capturing_preambleRR   RB   t   mot   lastlinet   eolmoRS   RA   t   payloadt	   firstlinet   bolmo(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyR+   Ä   sL   
					


	
!	


#c   
      C   sþ  d } g  } xÃt  | ƒ D]µ\ } } | d d k rv | sc t j | ƒ } |  j j j | ƒ q n  | j | ƒ q n  | rµ t j | ƒ d  j d ƒ } | |  j | <d g  } } n  | j	 d ƒ rj| d k rt
 j | ƒ } | r| t | j d ƒ ƒ  } n  |  j j | ƒ q qj| t | ƒ d k rB|  j j | ƒ d  St j | ƒ } |  j j j | ƒ q n  | j d ƒ }	 |	 d k  r­t j | ƒ } |  j j j | ƒ q n  | |	  } | |	 d j ƒ  g } q W| rút j | ƒ j d ƒ |  j | <n  d  S(	   NR   i    s    	iÿÿÿÿs   
s   From i   t   :(   t	   enumerateR   t#   FirstHeaderLineIsContinuationDefectR.   R8   R   RH   R   t   rstript
   startswithRO   RP   RQ   RN   t   set_unixfromR)   R   t   MisplacedEnvelopeHeaderDefectt   findt   MalformedHeaderDefectt   lstrip(
   R
   R    t
   lastheadert	   lastvaluet   linenoR   t   defectt   lhdrR^   t   i(    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyRF   °  sH    
(   R%   R&   R'   R   t   MessageR   R1   R3   R2   R   R?   R5   R+   RF   (    (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyR    Š   s   					
		ì(    (   R'   t   __all__RK   t   emailR   R   RL   RE   RX   RO   t   NLCRE_crackRC   RH   t   NLt   objectR   R   R    (    (    (    s5   /opt/alt/python27/lib64/python2.7/email/feedparser.pyt   <module>   s   		_