Ë
    ì—0jo  ã                   ó�   — d Z g d¢ZddlmZmZ ddlmZmZ ddlm	Z	  G d„ d«      Z
 G d„ d	e
«      Z G d
„ d«      Z G d„ de«      Zy)z-A parser of RFC 2822 and MIME email messages.)ÚParserÚHeaderParserÚBytesParserÚBytesHeaderParserÚ
FeedParserÚBytesFeedParseré    )ÚStringIOÚTextIOWrapper)r   r   )Úcompat32c                   ó*   — e Zd Zdedœd„Zdd„Zdd„Zy)r   N©Úpolicyc                ó    — || _         || _        y)a…  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.

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        N)Ú_classr   )Úselfr   r   s      ú)/usr/local/lib/python3.12/email/parser.pyÚ__init__zParser.__init__   s   € ð* ˆŒØˆ�ó    c                 óø   — t        | j                  | j                  ¬«      }|r|j                  «        |j	                  d«      x}r%|j                  |«       |j	                  d«      x}rŒ%|j                  «       S )a\  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.
        r   i    )r   r   r   Ú_set_headersonlyÚreadÚfeedÚclose)r   ÚfpÚheadersonlyÚ
feedparserÚdatas        r   ÚparsezParser.parse)   sj   € ô   §¡°D·K±KÔ@ˆ
ÙØ×'Ñ'Ô)Ø—g‘g˜d“mÐ#ˆdÐ#Ø�O‰O˜DÔ!ð —g‘g˜d“mÐ#ˆdÑ#à×ÑÓ!Ð!r   c                 ó:   — | j                  t        |«      |¬«      S )a-  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   Útextr   s      r   ÚparsestrzParser.parsestr8   s   € ð �z‰zœ( 4›.°kˆzÓBÐBr   )N©F)Ú__name__Ú
__module__Ú__qualname__r   r   r   r#   © r   r   r   r      s   „ ð¨hô ó0"ôCr   r   c                   ó   — e Zd Zdd„Zdd„Zy)r   c                 ó0   — t         j                  | |d«      S ©NT)r   r   ©r   r   r   s      r   r   zHeaderParser.parseD   s   € Ü�|‰|˜D " dÓ+Ð+r   c                 ó0   — t         j                  | |d«      S r+   )r   r#   r!   s      r   r#   zHeaderParser.parsestrG   s   € Ü�‰˜t T¨4Ó0Ð0r   N©T)r%   r&   r'   r   r#   r(   r   r   r   r   C   s   „ ó,ô1r   r   c                   ó"   — e Zd Zd„ Zdd„Zdd„Zy)r   c                 ó$   — t        |i |¤Ž| _        y)aÐ  Parser of binary 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 input 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 input 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.
        N)r   Úparser)r   ÚargsÚkws      r   r   zBytesParser.__init__M   s   € ô  ˜dÐ) bÑ)ˆ�r   c                 ó¢   — t        |dd¬«      }	 | j                  j                  ||«      |j                  «        S # |j                  «        w xY w)ac  Create a message structure from the data in a binary 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.
        ÚasciiÚsurrogateescape)ÚencodingÚerrors)r
   r1   r   Údetachr,   s      r   r   zBytesParser.parse_   s?   € ô ˜2¨Ð8IÔJˆð	Ø—;‘;×$Ñ$ R¨Ó5à�I‰I�KøˆB�I‰I�Kús	   �< ¼Ac                 ó`   — |j                  dd¬«      }| j                  j                  ||«      S )a2  Create a message structure from a byte 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.
        ÚASCIIr6   )r8   )Údecoder1   r#   r!   s      r   Ú
parsebyteszBytesParser.parsebytesn   s.   € ð �{‰{˜7Ð+<ˆ{Ó=ˆØ�{‰{×#Ñ# D¨+Ó6Ð6r   Nr$   )r%   r&   r'   r   r   r=   r(   r   r   r   r   K   s   „ ò*ó$ô	7r   r   c                   ó   — e Zd Zdd„Zdd„Zy)r   c                 ó2   — t         j                  | |d¬«      S ©NTr    )r   r   r,   s      r   r   zBytesHeaderParser.parse{   s   € Ü× Ñ   r°tÐ Ó<Ð<r   c                 ó2   — t         j                  | |d¬«      S r@   )r   r=   r!   s      r   r=   zBytesHeaderParser.parsebytes~   s   € Ü×%Ñ% d¨D¸dÐ%ÓCÐCr   Nr.   )r%   r&   r'   r   r=   r(   r   r   r   r   z   s   „ ó=ôDr   r   N)Ú__doc__Ú__all__Úior	   r
   Úemail.feedparserr   r   Úemail._policybaser   r   r   r   r   r(   r   r   Ú<module>rG      sN   ðñ
 4ò,€÷ 'ç 8Ý &÷0Cñ 0Côf1�6ô 1÷,7ñ ,7ô^D˜õ Dr   