
    9i                         S r SSKJr  SSKJr  SSKJr  / SQrSSKrSSKJrJ	r	  SSK
JrJr  SS	K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.    )unicode_literals)division)absolute_import)ParserHeaderParserBytesParserBytesHeaderParserN)StringIOTextIOWrapper)
FeedParserBytesFeedParser)Message)compat32c                   4    \ rS rSr\4S jrSS jrSS jrSrg)r      c                 D    SU;   a  US   o2S	 O[         nXl        X0l        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.

policyN)r   _classr   )selfr   _3to2kwargsr   s       ]/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/future/backports/email/parser.py__init__Parser.__init__   s*    * {"[-BFT\H]f    c                     [        U R                  U R                  S9nU(       a  UR                  5          UR	                  S5      nU(       d   UR                  5       $ UR                  U5        M<  )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/   s_      DKK@
'')774=D!! OOD!	 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.parsestrA   s     zz(4.kzBBr   )r   r   NF)	__name__
__module____qualname____firstlineno__r   r   r$   r*   __static_attributes__ r   r   r   r      s    % 4"$Cr   r   c                   (    \ rS rSrSS jrSS jrSrg)r   M   c                 .    [         R                  XS5      $ NT)r   r$   r   r    r!   s      r   r$   HeaderParser.parseN   s    ||Dd++r   c                 .    [         R                  XS5      $ r6   )r   r*   r(   s      r   r*   HeaderParser.parsestrQ   s    t400r   r2   NT)r-   r.   r/   r0   r$   r*   r1   r2   r   r   r   r   M   s    ,1r   r   c                   .    \ rS rSrS rSS jrSS jrSrg)r   U   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__W   s      d)b)r   c                     [        USSS9nU   U R                  R                  X5      sSSS5        $ ! , (       d  f       g= 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errorsN)r   r?   r$   r7   s      r   r$   BytesParser.parsei   s2     28IJ;;$$R5 RRs	   3
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.
ASCIIrE   )rG   )decoder?   r*   r(   s      r   
parsebytesBytesParser.parsebytesv   s,     {{7+<{={{##D66r   )r?   Nr,   )r-   r.   r/   r0   r   r$   rL   r1   r2   r   r   r   r   U   s    *$
6	7r   r   c                   (    \ rS rSrSS jrSS jrSrg)r	      c                 *    [         R                  XSS9$ NTr'   )r   r$   r7   s      r   r$   BytesHeaderParser.parse   s      t <<r   c                 *    [         R                  XSS9$ rQ   )r   rL   r(   s      r   rL   BytesHeaderParser.parsebytes   s    %%dd%CCr   r2   Nr;   )r-   r.   r/   r0   r$   rL   r1   r2   r   r   r	   r	      s    =Dr   r	   )__doc__
__future__r   r   r   __all__warningsior
   r   !future.backports.email.feedparserr   r   future.backports.email.messager   "future.backports.email._policybaser   objectr   r   r   r	   r2   r   r   <module>r^      s]   
 4 '  &
H  & I 2 75CV 5Cr16 1*7& *7ZD Dr   