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



]Y@sddgZddlZddlmZddlmZddlmZddlmZddl	m
Z
ejd	Zejd
Z
ejdZejd
ZejdZd
ZdZeZGdddeZGdddZGdddeZdS)
FeedParserBytesFeedParserN)errors)message)compat32)deque)StringIOz
|
|
z(
|
|
)z
(
|
|
)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])
c@seZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
ddZddZdS)BufferedSubFilecCs4tdd|_t|_g|_d|_dS)Nnewliner	F)r_partialr_lines	_eofstack_closed)selfr//opt/alt/python35/lib64/python3.5/feedparser.py__init__6s	zBufferedSubFile.__init__cCs|jj|dS)N)rappend)rZpredrrrpush_eof_matcherAsz BufferedSubFile.push_eof_matchercCs
|jjS)N)rpop)rrrrpop_eof_matcherDszBufferedSubFile.pop_eof_matchercCsP|jjd|j|jj|jjd|jjd|_dS)NrT)r
seek	pushlines	readlinestruncater)rrrrcloseGs

zBufferedSubFile.closecCsg|js|jrdStS|jj}x7t|jD]&}||r9|jj|dSq9W|S)Nr	)rrNeedMoreDatapopleftreversedr
appendleft)rlineZateofrrrreadlineOs		zBufferedSubFile.readlinecCs|jj|dS)N)rr!)rr"rrr
unreadlineaszBufferedSubFile.unreadlinecCs|jj|d|kr,d|kr,dS|jjd|jj}|jjd|jj|djds|jj|j|j|dS)Nr

r)r
writerrrendswithrr)rdatapartsrrrpushfs
zBufferedSubFile.pushcCs|jj|dS)N)rextend)rlinesrrrr{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@seZdZddeddZddZddZd	d
ZddZd
dZ	ddZ
ddZddZdS)rNpolicycCs||_d|_|dkrK|jtkr<tj|_qtj|_n;||_y|d|jWntk
rd|_YnXt|_	g|_
|jj|_
d|_d|_d|_dS)NFr5T)r5_old_style_factoryrrZMessage_factoryZEmailMessage	TypeErrorr_input	_msgstack	_parsegenr1_parse_cur_last_headersonly)rr7r5rrrrs"			
			zFeedParser.__init__cCs
d|_dS)NT)r?)rrrr_set_headersonlyszFeedParser._set_headersonlycCs|jj||jdS)N)r9r,_call_parse)rr*rrrfeedszFeedParser.feedcCs'y|jWntk
r"YnXdS)N)r<r0)rrrrrAs
zFeedParser._call_parsecCse|jj|j|j}|jdkra|jratj}|jj	|||S)N	multipart)
r9rrA_pop_messageget_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr5
handle_defect)rrootdefectrrrrs


zFeedParser.closecCs|jr|j}n|jd|j}|jrX|jjdkrX|jd|jru|jdj||jj|||_||_	dS)Nr5zmultipart/digestzmessage/rfc822r&r')
r6r7r5r=get_content_typeZset_default_typer:Zattachrr>)rmsgrrr_new_messages	
		zFeedParser._new_messagecCs8|jj}|jr+|jd|_n	d|_|S)Nr&r')r:rr=)rretvalrrrrDs
		zFeedParser._pop_messageccs|jg}x|jD]x}|tkr4tVqtj|stj|stj}|jj	|j
||jj|P|j|qW|j
||jrg}xA|jj}|tkrtVq|dkrP|j|qW|j
jtj|dS|j
jdkrx|jjtjx)|jD]}|tkretVqKPqKW|j}|jjx(|jj}|tkrtVqPqWx(|jj}|tkrtVqPqW|dkrP|jj|q+WdS|j
jdkrMx)|jD]}|tkr:tVq Pq W|jdS|j
jdkrv|j
j}|dkrtj}|jj	|j
|g}x2|jD]'}|tkrtVq|j|qW|j
jtj|dS|j
jddjdkr:tj}|jj	|j
|d	|}tjd
tj |d}	d}
g}d
}d
}
x|jj}|tkrtVq|dkrP|	j|}|r|j!drd}
|j!d}P|
rf|rM|d}t"j#|}|r8|dt$|j!d|d<tj||j
_%d
}
|jj|qxM|jj}|tkrtVqi|	j|}|si|jj|PqiW|jj|	jx)|jD]}|tkrtVqPqW|j&jdkr|j&j'}|dkr1d|j&_'q|dk	rt"j#|}|rt$|j!d}|d||j&_'n\|j&j(}t)|t*rt"j#|}|r|dt$|j!d}||j&_(|jj|j|j
|_&q|j|qW|
rtj+}|jj	|j
||j
jtj|g}x%|jD]}|tkretVqeqeWtj||j
_'dS|
stj,}|jj	|j
|dS|rdg}ng}x2|jD]'}|tkrtVq|j|qW|r]|d}t-j|}|r]|t$|j!dd|d<tj||j
_'dSg}x2|jD]'}|tkrtVq|j|qW|j
jtj|dS)Nr	zmessage/delivery-statusrrCzcontent-transfer-encoding8bit7bitbinaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TFendlinesepr&r)rNrMrOr'r').rKr9rheaderREmatchNLCRErZ MissingHeaderBodySeparatorDefectr5rFr=r$r_parse_headersr?r#Zset_payloadEMPTYSTRINGjoinrIrr;rDrrEZget_boundaryZNoBoundaryInMultipartDefectgetlowerZ-InvalidMultipartContentTransferEncodingDefectrecompileescapegroup	NLCRE_eolsearchlenpreambler>epilogueZ_payload
isinstancestrZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect	NLCRE_bol)rZheadersr"rHr.rLrJboundaryZ	separatorZ
boundaryreZcapturing_preamblerarQZclose_boundary_seenmoZlastlineZeolmorbrPZpayload	firstlineZbolmorrrr;sf

	

	


$ 


#zFeedParser._parsegenc	Csd}g}xt|D]\}}|ddkrs|sctj|}|jj|j|q|j|q|r|jj|jj|dg}}|j	drW|dkrt
j|}|r|dt|j
d}|jj|qnO|t|dkr2|jj|dStj|}|jjj|q|jd}|dkrtjd}|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$ZMisplacedEnvelopeHeaderDefectZdefectsfindZInvalidHeaderDefect)	rr.Z
lastheaderZ	lastvaluelinenor"rHrgirrrrUsF

 
zFeedParser._parse_headers)
r2r3r4rrr@rBrArrKrDr;rUrrrrrs!

cs"eZdZfddZS)rcs tj|jdddS)Nasciisurrogateescape)superrBdecode)rr*)	__class__rrrBszBytesFeedParser.feed)r2r3r4rBrr)rsrrs)__all__rZZemailrrZemail._policybasercollectionsriorr[rTrer^ZNLCRE_crackrRrVNLobjectrrrrrrrr<module>s$	[
Back to Directory File Manager