;ς
ίp>c           @   s»   d  Z  d k Z d k l Z d k l Z d k l Z d k l Z d Z	 d Z
 y e e f Wn e j
 o d Z d	 Z n Xe i d
  Z d f  d     YZ d e f d     YZ d S(   s.   A parser of RFC 2822 and MIME email messages.
N(   s   StringIO(   s   ListType(   s   Errors(   s   Messages    s   
i   i    s   
||
s   Parserc           B   sG   t  Z e i e d  Z e d  Z e d  Z d   Z e d  Z	 RS(   Nc         C   s   | |  _  | |  _ d S(   s"  Parser of RFC 2822 and MIME email messages.

        Creates an in-memory object tree representing the email message, which
        can then be manipulated and turned over to a Generator to return the
        textual representation of the message.

        The string must be formatted as a block of RFC 2822 headers and header
        continuation lines, optionally preceeded by a `Unix-from' header.  The
        header block is terminated either by the end of the string or by a
        blank line.

        _class is the class to instantiate for new message objects when they
        must be created.  This class must have a constructor that can take
        zero arguments.  Default is Message.Message.

        Optional strict tells the parser to be strictly RFC compliant or to be
        more forgiving in parsing of ill-formatted MIME documents.  When
        non-strict mode is used, the parser will try to make up for missing or
        erroneous boundaries and other peculiarities seen in the wild.
        Default is non-strict parsing.
        N(   s   _classs   selfs   stricts   _strict(   s   selfs   _classs   strict(    (    s.   /usr/pkg/lib/mailman/pythonlib/email/Parser.pys   __init__   s     	c         C   sE   |  i   } |  i | |  } | o |  i | | |  n | Sd S(   s\  Create a message structure from the data in a file.

        Reads all the data from the file and returns the root of the message
        structure.  Optional headersonly is a flag specifying whether to stop
        parsing after reading the headers or not.  The default is False,
        meaning it parses the entire contents of the file.
        N(   s   selfs   _classs   roots   _parseheaderss   fps   firstbodylines   headersonlys
   _parsebody(   s   selfs   fps   headersonlys   roots   firstbodyline(    (    s.   /usr/pkg/lib/mailman/pythonlib/email/Parser.pys   parse5   s     c         C   s   |  i t |  d | Sd S(   s-  Create a message structure from a string.

        Returns the root of the message structure.  Optional headersonly is a
        flag specifying whether to stop parsing after reading the headers or
        not.  The default is False, meaning it parses the entire contents of
        the file.
        s   headersonlyN(   s   selfs   parses   StringIOs   texts   headersonly(   s   selfs   texts   headersonly(    (    s.   /usr/pkg/lib/mailman/pythonlib/email/Parser.pys   parsestrC   s     c   	      C   sΝ  d } g  } d } t } xt o| i   } | o Pn | i	   d } | o Pn | d 7} | i
 d  oE | d j o | i |  q q· |  i o t i d   q· q n | d d j o/ | o t i d   n | i |  q n | i d  } | d j  oP |  i o t i d	 |   qc| d j o | i
 d
  o q qc| } Pn | o t i |  | | <n | |  } | | d i   g } q W| o t i |  | | <n | Sd  S(   Ns    i    i   s   From s.   Unix-from in headers after first rfc822 headers    	s*   Continuation line seen before first headers   :s(   Not a header, not a continuation: ``%s''s   --(   s
   lastheaders	   lastvalues   linenos   Nones   firstbodylines   Trues   fps   readlines   lines
   splitliness
   startswiths	   containers   set_unixfroms   selfs   _stricts   Errorss   HeaderParseErrors   appends   finds   is   NLs   joins   lstrip(	   s   selfs	   containers   fps	   lastvalues   is   firstbodylines   linenos   lines
   lastheader(    (    s.   /usr/pkg/lib/mailman/pythonlib/email/Parser.pys   _parseheadersM   sP     



c         C   sΦ  | i   } | i   d j } | ont } } d | } | i
   }
 | t j	 o | d |
 }
 n t i d t i |  d |
  } | o6 |  i o t i d |   n | i |
  d  Sn | i   } | d j o |
 d | !} n | t | i d   t | i d	   7} t i |
 |  } | o | t | i d   7} n t i d
 t i |  d  } | i |
 |  } | oL | i   } | i d  } | i   t |
  j  o |
 | i   } q]n |  i o t i d |   ng t i d |
  } | o1 t i d |
  } | o t i d   qBn | i d  } t |
  } t i | t i |  d | |
 | | ! } xD| D]ω } | oΎ | i" |  o  |  i#   } | t |  } n2 | i | | d  \ } } |  i& | d d } | i' d  | i(   }	 |	 d d f j o  |  i& |  } | i+ |  ql| i |  n |  i& |  } | | _ | | _ | i+ |  qWn@| i,   d j o t i d   n| i-   d j ob g  } xH t/ o@ |  i#   } |  i1 | |  t |  o Pn | i2 |  qΥW| i |  n₯ | i,   d j oY y |  i3 |  } Wn2 t i5 j
 o# |  i#   } |  i6 | |  n X| i+ |  n9 | i
   } | t j	 o | d | } n | i |  d  S(   Ns   multipart/digests   --s   
s   (?P<sep>s   )(?P<ws>[ \t]*)s#   Couldn't find starting boundary: %si    s   seps   wss   (?P<sep>
||
)s&   Couldn't find terminating boundary: %ss   (?P<sep>
||
){2}$s   (?P<sep>
||
)$s2   No terminating boundary and no trailing empty lines   [ \t]*i   s   headersonlys   message/rfc822s   messages	   multiparts*   multipart message with no defined boundarys   message/delivery-status(8   s	   containers   get_boundarys   boundarys   get_content_types   isdigests   Nones   preambles   epilogues	   separators   fps   reads   payloads   firstbodylines   res   searchs   escapes   mos   selfs   _stricts   Errorss   BoundaryErrors   set_payloads   starts   lens   groups   NLCREs   compiles   cres
   terminators   lineseps   ends   splits   partss   parts
   startswiths   _classs   msgobjs   parthdrss   parsestrs   set_default_types   get_content_maintypes   maintypes	   submsgobjs   attachs   get_main_types   get_types   blockss   Trues   blockmsgs   _parseheaderss   appends   parses   msgs   HeaderParseErrors
   _parsebodys   text(   s   selfs	   containers   fps   firstbodylines   texts	   submsgobjs
   terminators   blockss   blockmsgs   maintypes   payloads   preambles   lineseps   starts   partss   msgs   boundarys   msgobjs   parts   epilogues   mos	   separators   cres   isdigests   parthdrs(    (    s.   /usr/pkg/lib/mailman/pythonlib/email/Parser.pys
   _parsebody   s’    

	
, 
 		 (
   s   __name__s
   __module__s   Messages   Falses   __init__s   parses   parsestrs   _parseheaderss   Nones
   _parsebody(    (    (    s.   /usr/pkg/lib/mailman/pythonlib/email/Parser.pys   Parser   s
   
	Bs   HeaderParserc           B   s   t  Z d  Z e d  Z RS(   s  A subclass of Parser, this one only meaningfully parses message headers.

    This class can be used if all you're interested in is the headers of a
    message.  While it consumes the message body, it does not parse it, but
    simply makes it available as a string payload.

    Parsing with this subclass can be considerably faster if all you're
    interested in is the message headers.
    c         C   s<   | i   } | t j	 o | d | } n | i |  d  S(   Ns   
(   s   fps   reads   texts   firstbodylines   Nones	   containers   set_payload(   s   selfs	   containers   fps   firstbodylines   text(    (    s.   /usr/pkg/lib/mailman/pythonlib/email/Parser.pys
   _parsebody  s    (   s   __name__s
   __module__s   __doc__s   Nones
   _parsebody(    (    (    s.   /usr/pkg/lib/mailman/pythonlib/email/Parser.pys   HeaderParser  s   	 (   s   __doc__s   res	   cStringIOs   StringIOs   typess   ListTypes   emails   Errorss   Messages   EMPTYSTRINGs   NLs   Trues   Falses	   NameErrors   compiles   NLCREs   Parsers   HeaderParser(   s   Errorss   NLs   StringIOs   Parsers   EMPTYSTRINGs   res   HeaderParsers   NLCREs   ListTypes   Falses   Messages   True(    (    s.   /usr/pkg/lib/mailman/pythonlib/email/Parser.pys   ?   s   	ϊ