Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib/python3.7/site-packages/future/backports/email/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/future/backports/email/__pycache__/feedparser.cpython-37.pyc

B

�A�[�X�@s�dZddlmZddlmZddlmZddlmZmZmZddl	m
Z
mZddgZdd	l
Z
dd
lmZddlmZddlmZe
�d
�Ze
�d�Ze
�d�Ze
�d�Ze
�d�ZdZdZe�ZGdd�de�ZGdd�de�ZGdd�de�Zd	S)aFeedParser - An email feed parser.

The feed parser implements an interface for incrementally parsing an email
message, line by line.  This has advantages for certain applications, such as
those reading email messages off a socket.

FeedParser.feed() is the primary interface for pushing new data into the
parser.  It returns when there's nothing more it can do with the available
data.  When you have no more data to push into the parser, call .close().
This completes the parsing and returns the root message object.

The other advantage of this parser is that it will never raise a parsing
exception.  Instead, when it finds something unexpected, it adds a 'defect' to
the current message.  Defects are just instances that live on the message
object's .defects attribute.
�)�unicode_literals)�division)�absolute_import)�object�range�super)�implements_iterator�PY3�
FeedParser�BytesFeedParserN)�errors)�message)�compat32z
|
|
z(
|
|
)z
(
|
|
)\Zz(^(From |[\041-\071\073-\176]{1,}:|[\t ])��
c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BufferedSubFileakA file-ish object that can have new data loaded into it.

    You can also push and pop line-matching predicates onto a stack.  When the
    current predicate matches the current line, a false EOF response
    (i.e. empty string) is returned instead.  This lets the parser adhere to a
    simple abstraction -- it parses until EOF closes the current message.
    cCsd|_g|_g|_d|_dS)NrF)�_partial�_lines�	_eofstack�_closed)�self�r�R/opt/alt/python37/lib/python3.7/site-packages/future/backports/email/feedparser.py�__init__9szBufferedSubFile.__init__cCs|j�|�dS)N)r�append)r�predrrr�push_eof_matcherCsz BufferedSubFile.push_eof_matchercCs
|j��S)N)r�pop)rrrr�pop_eof_matcherFszBufferedSubFile.pop_eof_matchercCs|j�|j�d|_d|_dS)NrT)rrrr)rrrr�closeIszBufferedSubFile.closecCsT|js|jrdStS|j��}x0|jddd�D]}||�r0|j�|�dSq0W|S)Nr���)rr�NeedMoreDatarrr)r�line�ateofrrr�readlineOs
zBufferedSubFile.readlinecCs|tk	st�|j�|�dS)N)r!�AssertionErrorrr)rr"rrr�
unreadlineaszBufferedSubFile.unreadlinecCs�|j|d}|_t�|�}|��|_|jsR|rR|d�d�rR|�d�|��|_g}x:tt|�d�D]&}|�||d||dd�qhW|�|�dS)z$Push some new data into this object.rr �
�����N)	r�NLCRE_crack�splitr�endswithr�lenr�	pushlines)r�data�parts�lines�irrr�pushfs

&zBufferedSubFile.pushcCs|ddd�|jdd�<dS)Nr r)r)rr2rrrr/}szBufferedSubFile.pushlinescCs|S)Nr)rrrr�__iter__�szBufferedSubFile.__iter__cCs|��}|dkrt�|S)Nr)r$�
StopIteration)rr"rrr�__next__�szBufferedSubFile.__next__N)�__name__�
__module__�__qualname__�__doc__rrrrr$r&r4r/r5r7rrrrr1s
rc@s^eZdZdZejfdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)r
zA feed-style parser of email.cs�d|kr|d}|d=nt}|�_|�_y|�jd��fdd��_Wntk
rddd��_YnXt��_g�_tr���	�j
�_n��	�j�_d�_
d�_d�_dS)N�policy)r<cs
d�jiS)Nr<)r<r)rrr�<lambda>��z%FeedParser.__init__.<locals>.<lambda>cSsiS)Nrrrrrr=�r>F)r�_factoryr<�
_factory_kwds�	TypeErrorr�_input�	_msgstackr	�	_parsegenr7�_parse�next�_cur�_last�_headersonly)rr?Z_3to2kwargsr<r)rrr�s&zFeedParser.__init__cCs
d|_dS)NT)rI)rrrr�_set_headersonly�szFeedParser._set_headersonlycCs|j�|�|��dS)zPush more data into the parser.N)rBr4�_call_parse)rr0rrr�feed�szFeedParser.feedcCs&y|��Wntk
r YnXdS)N)rEr6)rrrrrK�szFeedParser._call_parsecCsR|j��|��|��}|jr$t�|��dkrN|��sNt�	�}|j
�||�|S)z<Parse all remaining data and return the root message object.�	multipart)rBrrK�_pop_messagerCr%�get_content_maintype�is_multipartr�!MultipartInvariantViolationDefectr<�
handle_defect)r�root�defectrrrr�s

zFeedParser.closecCs`|jf|���}|jr.|j��dkr.|�d�|jrD|jd�|�|j�|�||_||_dS)Nzmultipart/digestzmessage/rfc822r )	r?r@rG�get_content_type�set_default_typerC�attachrrH)r�msgrrr�_new_message�s
zFeedParser._new_messagecCs(|j��}|jr|jd|_nd|_|S)Nr )rCrrG)r�retvalrrrrN�s

zFeedParser._pop_messageccs@|��g}xb|jD]X}|tkr(tVqt�|�sbt�|�s`t��}|j�	|j
|�|j�|�P|�|�qW|�
|�|jr�g}x2|j��}|tkr�tVq�|dkr�P|�|�q�W|j
�t�|��dS|j
��dk�r�x�|j�tj�x$|��D]}|tk�rtVq�Pq�W|��}|j��x&|j��}|tk�rFtV�q(P�q(Wx&|j��}|tk�rntV�qPP�qPW|dk�r�P|j�|�q�WdS|j
��dk�r�x(|��D]}|tk�r�tV�q�P�q�W|��dS|j
��dk�r�|j
��}|dk�rbt��}|j�	|j
|�g}x.|jD]$}|tk�r<tV�q$|�|��q$W|j
�t�|��dS|j
�dd���dk�r�t��}|j�	|j
|�d|}t�d	t� |�d
�}	d}
g}d}d}
�x|j��}|tk�r�tV�q�|dk�r�P|	�|�}|�r�|�!d
��rd}
|�!d�}P|
�r~|�rj|d}t"�#|�}|�r\|dt$|�!d���|d<t�|�|j
_%d}
|j�|��q�xB|j��}|tk�r�tV�q�|	�|�}|�s�|j�|�P�q�W|j�|	j�x(|��D]}|tk�r�tV�q�P�q�W|j&��dk�rb|j&j'}|dk�r&d|j&_'n:|dk	�r�t"�#|�}|�r�t$|�!d��}|d|�|j&_'nD|j&j(}t)|t*��r�t"�#|�}|�r�|dt$|�!d���}||j&_(|j��|��|j
|_&n|
�s�t+�|�|��q�W|
�rHt�,�}|j�	|j
|�|j
�t�|��g}x$|jD]}|tk�rtV�q�qWt�|�|j
_'dS|
�sjt�-�}|j�	|j
|�dS|�rxdg}ng}x.|jD]$}|tk�r�tV�q�|�|��q�W|�r�|d}t.�|�}|�r�|t$|�!d��d�|d<t�|�|j
_'dSg}x.|jD]$}|tk�rtV�q|�|��qW|j
�t�|��dS)Nrzmessage/delivery-statusr
rMzcontent-transfer-encoding�8bit)�7bitr[�binaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�linesepr r)/rYrBr!�headerRE�match�NLCREr� MissingHeaderBodySeparatorDefectr<rRrGr&r�_parse_headersrIr$�set_payload�EMPTYSTRING�joinrUrrDrNrrO�get_boundary�NoBoundaryInMultipartDefect�get�lower�-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�searchr.�preamblerH�epilogue�_payload�
isinstance�strr%�StartBoundaryNotFoundDefect�CloseBoundaryNotFoundDefect�	NLCRE_bol)r�headersr"rTr2rZrX�boundary�	separator�
boundaryre�capturing_preamblersr_�close_boundary_seen�mo�lastline�eolmortr^�payload�	firstline�bolmorrrrD�sh





































zFeedParser._parsegenc	CsJd}g}�x t|�D�]\}}|ddkrV|sJt�|�}|j�|j|�q|�|�q|rx|jj|j�|��dg}}|�	d�r�|dkr�t
�|�}|r�|dt|�
d���}|j�|�qn:|t|�dkr�|j�|�dSt�|�}|jj�|�q|�d�}|dk�std��|d|�}|g}qW|�rF|jj|j�|��dS)Nrrz 	zFrom r*�:z3_parse_headers fed line with no : and no leading WS)�	enumerater�#FirstHeaderLineIsContinuationDefectr<rRrGr�set_raw�header_source_parse�
startswithrqrrr.rp�set_unixfromrBr&�MisplacedEnvelopeHeaderDefect�defects�findr%)	rr2�
lastheader�	lastvalue�linenor"rTr�r3rrrrd�s@







zFeedParser._parse_headersN)r8r9r:r;r
�MessagerrJrLrKrrYrNrDrdrrrrr
�s

~cs eZdZdZ�fdd�Z�ZS)rz(Like FeedParser, but feed accepts bytes.cst��|�dd��dS)N�ascii�surrogateescape)rrL�decode)rr0)�	__class__rrrLszBytesFeedParser.feed)r8r9r:r;rL�
__classcell__rr)r�rr	s)r;�
__future__rrrZfuture.builtinsrrrZfuture.utilsrr	�__all__rmZfuture.backports.emailrr
Z"future.backports.email._policybaserrnrbrzrqr+r`rf�NLr!rr
rrrrr�<module>s0




Z

Hacked By AnonymousFox1.0, Coded By AnonymousFox