ó
è¾bc           @   s{   d  Z  d d g Z d d l Z d d l m Z d d l m Z d d l m Z d d
 d „  ƒ  YZ	 d e	 f d	 „  ƒ  YZ
 d S(   s-   A parser of RFC 2822 and MIME email messages.t   Parsert   HeaderParseriÿÿÿÿN(   t   StringIO(   t
   FeedParser(   t   Messagec           B   s)   e  Z d  „  Z e d „ Z e d „ Z RS(   c         O   s  t  | ƒ d k r> d | k r- t d ƒ ‚ n  | d | d <n  t  | ƒ d k r| d | k rk t d ƒ ‚ n  | d | d <n  t  | ƒ d k r t d ƒ ‚ n  d | k rÀ | d |  _ | d =n	 t |  _ d | k rò t j d	 t d ƒ | d =n  | rt d
 ƒ ‚ n  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 preceded 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.
        i   t   _classs(   Multiple values for keyword arg '_class'i    i   t   stricts(   Multiple values for keyword arg 'strict's   Too many argumentss-   'strict' argument is deprecated (and ignored)s   Unexpected keyword argumentsN(   t   lent	   TypeErrorR   R   t   warningst   warnt   DeprecationWarning(   t   selft   argst   kws(    (    s"   /usr/lib/python2.7/email/parser.pyt   __init__   s(    
		

c         C   s_   t  |  j ƒ } | r" | j ƒ  n  x0 t rT | j d ƒ } | sD Pn  | j | ƒ q% W| j ƒ  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.
        i    (   R   R   t   _set_headersonlyt   Truet   readt   feedt   close(   R   t   fpt   headersonlyt
   feedparsert   data(    (    s"   /usr/lib/python2.7/email/parser.pyt   parse8   s    	c         C   s   |  j  t | ƒ d | ƒ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.
        R   (   R   R   (   R   t   textR   (    (    s"   /usr/lib/python2.7/email/parser.pyt   parsestrJ   s    (   t   __name__t
   __module__R   t   FalseR   R   (    (    (    s"   /usr/lib/python2.7/email/parser.pyR       s   	&c           B   s    e  Z e d  „ Z e d „ Z RS(   c         C   s   t  j |  | t ƒ S(   N(   R    R   R   (   R   R   R   (    (    s"   /usr/lib/python2.7/email/parser.pyR   W   s    c         C   s   t  j |  | t ƒ S(   N(   R    R   R   (   R   R   R   (    (    s"   /usr/lib/python2.7/email/parser.pyR   Z   s    (   R   R   R   R   R   (    (    (    s"   /usr/lib/python2.7/email/parser.pyR   V   s   (    (   t   __doc__t   __all__R	   t	   cStringIOR   t   email.feedparserR   t   email.messageR   R    R   (    (    (    s"   /usr/lib/python2.7/email/parser.pyt   <module>   s   E