AlkantarClanX12

Your IP : 13.59.234.182


Current Path : /opt/alt/python35/lib64/python3.5/email/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/email/__pycache__/feedparser.cpython-35.opt-2.pyc



���]�Y�@sddgZddlZddlmZddlmZddlmZddlmZddl	m
Z
ejd	�Zejd
�Z
ejd�Zejd
�Zejd�Zd
ZdZe�ZGdd�de�ZGdd�d�ZGdd�de�ZdS)�
FeedParser�BytesFeedParser�N)�errors)�message)�compat32)�deque)�StringIOz
|
|
z(
|
|
)z
(
|
|
)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])��
c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�BufferedSubFilecCs4tdd�|_t�|_g|_d|_dS)N�newliner	F)r�_partialr�_lines�	_eofstack�_closed)�self�r�//opt/alt/python35/lib64/python3.5/feedparser.py�__init__6s	zBufferedSubFile.__init__cCs|jj|�dS)N)r�append)rZpredrrr�push_eof_matcherAsz BufferedSubFile.push_eof_matchercCs
|jj�S)N)r�pop)rrrr�pop_eof_matcherDszBufferedSubFile.pop_eof_matchercCsP|jjd�|j|jj��|jjd�|jj�d|_dS)NrT)r
�seek�	pushlines�	readlines�truncater)rrrr�closeGs

zBufferedSubFile.closecCsg|js|jrdStS|jj�}x7t|j�D]&}||�r9|jj|�dSq9W|S)Nr	)rr�NeedMoreData�popleft�reversedr�
appendleft)r�lineZateofrrr�readlineOs		zBufferedSubFile.readlinecCs|jj|�dS)N)rr!)rr"rrr�
unreadlineaszBufferedSubFile.unreadlinecCs�|jj|�d|kr,d|kr,dS|jjd�|jj�}|jjd�|jj�|djd�s�|jj|j��|j|�dS)Nr
�
r����)r
�writerrr�endswithrr)r�data�partsrrr�pushfs
zBufferedSubFile.pushcCs|jj|�dS)N)r�extend)r�linesrrrr{szBufferedSubFile.pushlinescCs|S)Nr)rrrr�__iter__~szBufferedSubFile.__iter__cCs"|j�}|dkrt�|S)Nr	)r#�
StopIteration)rr"rrr�__next__�szBufferedSubFile.__next__N)
�__name__�
__module__�__qualname__rrrrr#r$r,rr/r1rrrrr.src@s�eZdZddedd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)rN�policycCs�||_d|_|dkrK|jtkr<tj|_q�tj|_n;||_y|d|j�Wntk
r�d|_YnXt�|_	g|_
|j�j|_
d|_d|_d|_dS)NFr5T)r5�_old_style_factoryrrZMessage�_factoryZEmailMessage�	TypeErrorr�_input�	_msgstack�	_parsegenr1�_parse�_cur�_last�_headersonly)rr7r5rrrr�s"			
			zFeedParser.__init__cCs
d|_dS)NT)r?)rrrr�_set_headersonly�szFeedParser._set_headersonlycCs|jj|�|j�dS)N)r9r,�_call_parse)rr*rrr�feed�szFeedParser.feedcCs'y|j�Wntk
r"YnXdS)N)r<r0)rrrrrA�s
zFeedParser._call_parsecCse|jj�|j�|j�}|j�dkra|j�ratj�}|jj	||�|S)N�	multipart)
r9rrA�_pop_message�get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr5�
handle_defect)r�root�defectrrrr�s


zFeedParser.closecCs�|jr|j�}n|jd|j�}|jrX|jj�dkrX|jd�|jru|jdj|�|jj|�||_||_	dS)Nr5zmultipart/digestzmessage/rfc822r&r')
r6r7r5r=�get_content_typeZset_default_typer:Zattachrr>)r�msgrrr�_new_message�s	
		zFeedParser._new_messagecCs8|jj�}|jr+|jd|_n	d|_|S)Nr&r')r:rr=)r�retvalrrrrD�s
		zFeedParser._pop_messageccs�|j�g}x�|jD]x}|tkr4tVqtj|�s�tj|�s�tj�}|jj	|j
|�|jj|�P|j|�qW|j
|�|jrg}xA|jj�}|tkr�tVq�|dkr�P|j|�q�W|j
jtj|��dS|j
j�dkr�x�|jjtj�x)|j�D]}|tkretVqKPqKW|j�}|jj�x(|jj�}|tkr�tVq�Pq�Wx(|jj�}|tkr�tVq�Pq�W|dkr�P|jj|�q+WdS|j
j�dkrMx)|j�D]}|tkr:tVq Pq W|j�dS|j
j�dkrv|j
j�}|dkr�tj�}|jj	|j
|�g}x2|jD]'}|tkr�tVq�|j|�q�W|j
jtj|��dS|j
jdd�j�dkr:tj�}|jj	|j
|�d	|}tjd
tj |�d�}	d}
g}d
}d
}
x�|jj�}|tkr�tVq|dkr�P|	j|�}|r|j!d�r�d}
|j!d�}P|
rf|rM|d}t"j#|�}|r8|dt$|j!d���|d<tj|�|j
_%d
}
|jj|�qxM|jj�}|tkr�tVqi|	j|�}|si|jj|�PqiW|jj|	j�x)|j�D]}|tkr�tVq�Pq�W|j&j�dkr�|j&j'}|dkr1d|j&_'q�|dk	r�t"j#|�}|r�t$|j!d��}|d|�|j&_'n\|j&j(}t)|t*�r�t"j#|�}|r�|dt$|j!d���}||j&_(|jj�|j�|j
|_&q|j|�qW|
r�tj+�}|jj	|j
|�|j
jtj|��g}x%|jD]}|tkretVqeqeWtj|�|j
_'dS|
s�tj,�}|jj	|j
|�dS|r�dg}ng}x2|jD]'}|tkrtVq�|j|�q�W|r]|d}t-j|�}|r]|t$|j!d��d�|d<tj|�|j
_'dSg}x2|jD]'}|tkr�tVq�|j|�q�W|j
jtj|��dS)Nr	zmessage/delivery-statusrrCzcontent-transfer-encoding�8bit�7bit�binaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TF�end�linesepr&r)rNrMrOr'r').rKr9r�headerRE�match�NLCRErZ MissingHeaderBodySeparatorDefectr5rFr=r$r�_parse_headersr?r#Zset_payload�EMPTYSTRING�joinrIrr;rDrrEZget_boundaryZNoBoundaryInMultipartDefect�get�lowerZ-InvalidMultipartContentTransferEncodingDefect�re�compile�escape�group�	NLCRE_eol�search�len�preambler>�epilogueZ_payload�
isinstance�strZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect�	NLCRE_bol)rZheadersr"rHr.rLrJ�boundaryZ	separatorZ
boundaryreZcapturing_preamblerarQZclose_boundary_seen�moZlastlineZeolmorbrPZpayload�	firstlineZbolmorrrr;�sf

	

	


$ 


#zFeedParser._parsegenc	Cs�d}g}x�t|�D]�\}}|ddkrs|sctj|�}|jj|j|�q|j|�q|r�|jj|jj|��dg}}|j	d�rW|dkrt
j|�}|r�|dt|j
d���}|jj|�qnO|t|�dkr2|jj|�dStj|�}|jjj|�q|jd�}|dkr�tjd�}|jjj|�q|d|�}|g}qW|r�|jj|jj|��dS)Nr	rz 	zFrom r&�:zMissing header name.)�	enumeraterZ#FirstHeaderLineIsContinuationDefectr5rFr=rZset_rawZheader_source_parse�
startswithr^r_r`r]Zset_unixfromr9r$ZMisplacedEnvelopeHeaderDefectZdefects�findZInvalidHeaderDefect)	rr.Z
lastheaderZ	lastvalue�linenor"rHrg�irrrrU�sF

 
zFeedParser._parse_headers)
r2r3r4rrr@rBrArrKrDr;rUrrrrr�s!

�cs"eZdZ�fdd�Z�S)rcs t�j|jdd��dS)N�ascii�surrogateescape)�superrB�decode)rr*)�	__class__rrrBszBytesFeedParser.feed)r2r3r4rBrr)rsrrs)�__all__rZZemailrrZemail._policybaser�collectionsr�iorr[rTrer^ZNLCRE_crackrRrV�NL�objectrrrrrrrr�<module>s$	[��