
    F\ho                         S r / SQrSSKJrJr  SSKJrJr  SSKJ	r	   " S S5      r
 " S S	\
5      r " S
 S5      r " S S\5      rg)z-A parser of RFC 2822 and MIME email messages.)ParserHeaderParserBytesParserBytesHeaderParser
FeedParserBytesFeedParser    )StringIOTextIOWrapper)r   r   )compat32c                   :    \ rS rSrS\S.S jjrS	S jrS	S jrSrg)
r      Npolicyc                    Xl         X l        g)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/lib/python3.13/email/parser.py__init__Parser.__init__   s    *     c                    [        U R                  U R                  S9nU(       a  UR                  5         UR	                  S5      =n(       a+  UR                  U5        UR	                  S5      =n(       a  M+  UR                  5       $ )a4  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   parseParser.parse)   sj      DKK@
'')ggdm#d#OOD! ggdm#d#!!r   c                 4    U R                  [        U5      US9$ )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   parsestrParser.parsestr8   s     zz(4.kzBBr   r   )NF)	__name__
__module____qualname____firstlineno__r   r   r!   r'   __static_attributes__ r   r   r   r      s    h 0"Cr   r   c                   (    \ rS rSrSS jrSS jrSrg)r   C   c                 .    [         R                  XS5      $ NT)r   r!   r   r   r   s      r   r!   HeaderParser.parseD   s    ||Dd++r   c                 .    [         R                  XS5      $ r3   )r   r'   r%   s      r   r'   HeaderParser.parsestrG   s    t400r   r/   NT)r*   r+   r,   r-   r!   r'   r.   r/   r   r   r   r   C   s    ,1r   r   c                   .    \ rS rSrS rSS jrSS jrSrg)r   K   c                 $    [        U0 UD6U l        g)ax  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   BytesParser.__init__M   s      d)b)r   c                     [        USSS9n U R                  R                  X5      UR                  5         $ ! UR                  5         f = f)a;  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
   r<   r!   detachr4   s      r   r!   BytesParser.parse_   s=     28IJ	;;$$R5IIKBIIKs	   8 A
c                 X    UR                  SSS9nU R                  R                  X5      $ )a
  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.
ASCIIrB   )rD   )decoder<   r'   r%   s      r   
parsebytesBytesParser.parsebytesn   s,     {{7+<{={{##D66r   )r<   Nr)   )r*   r+   r,   r-   r   r!   rJ   r.   r/   r   r   r   r   K   s    *$	7r   r   c                   (    \ rS rSrSS jrSS jrSrg)r   z   c                 *    [         R                  XSS9$ NTr$   )r   r!   r4   s      r   r!   BytesHeaderParser.parse{   s      t <<r   c                 *    [         R                  XSS9$ rO   )r   rJ   r%   s      r   rJ   BytesHeaderParser.parsebytes~   s    %%dd%CCr   r/   Nr8   )r*   r+   r,   r-   r!   rJ   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>rX      sN   
 4, ' 8 &0C 0Cf16 1,7 ,7^D Dr   