MINI MINI MANI MO

Path : /lib64/python3.6/email/__pycache__/
File Upload :
Current File : //lib64/python3.6/email/__pycache__/feedparser.cpython-36.pyc

3


 \X@sdZddgZddlZddlmZddlmZddlmZddl	m
Z
ejd	Zejd
Z
ejdZejd
ZejdZd
ZdZeZGdddeZGdddZGdddeZdS)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.

FeedParserBytesFeedParserN)errors)compat32)deque)StringIOz
\r\n|\r|\nz(\r\n|\r|\n)z(\r\n|\r|\n)\Zz%^(From |[\041-\071\073-\176]*:|[\t ])
c@s`eZdZdZddZddZddZdd	Zd
dZdd
Z	ddZ
ddZddZddZ
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.
    cCs$tdd|_t|_g|_d|_dS)Nr)newlineF)r_partialr_lines	_eofstack_closed)selfr(/usr/lib64/python3.6/email/feedparser.py__init__5szBufferedSubFile.__init__cCs|jj|dS)N)rappend)rZpredrrrpush_eof_matcher@sz BufferedSubFile.push_eof_matchercCs
|jjS)N)rpop)rrrrpop_eof_matcherCszBufferedSubFile.pop_eof_matchercCs<|jjd|j|jj|jjd|jjd|_dS)NrT)rseek	pushlines	readlinestruncater)rrrrcloseFs

zBufferedSubFile.closecCsN|js|jrdStS|jj}x*t|jD]}||r*|jj|dSq*W|S)Nr)r
rNeedMoreDatapopleftreversedr
appendleft)rlineZateofrrrreadlineNs
zBufferedSubFile.readlinecCs|tk	st|jj|dS)N)rAssertionErrorr
r )rr!rrr
unreadline`szBufferedSubFile.unreadlinecCsx|jj|d|kr d|kr dS|jjd|jj}|jjd|jj|djdsj|jj|j|j|dS)z$Push some new data into this object.r	
Nr)rwriterrrendswithrr)rdatapartsrrrpushes

zBufferedSubFile.pushcCs|jj|dS)N)r
extend)rlinesrrrrzszBufferedSubFile.pushlinescCs|S)Nr)rrrr__iter__}szBufferedSubFile.__iter__cCs|j}|dkrt|S)Nr)r"
StopIteration)rr!rrr__next__szBufferedSubFile.__next__N)__name__
__module____qualname____doc__rrrrr"r$r,rr/r1rrrrr
-sr
c@s`eZdZdZdedddZddZdd	Zd
dZdd
Z	ddZ
ddZddZddZ
dS)rzA feed-style parser of email.N)policycCs||_d|_|dkr<|jdkr2ddlm}||_qn|j|_n2||_y||jdWntk
rld|_YnXt|_g|_	|j
j|_d|_
d|_d|_dS)a_factory is called with no arguments to create a new message obj

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        FNr)Message)r6T)r6_old_style_factoryZmessage_factoryZ
email.messager7_factory	TypeErrorr
_input	_msgstack	_parsegenr1_parse_cur_last_headersonly)rr9r6r7rrrrs$

zFeedParser.__init__cCs
d|_dS)NT)rA)rrrr_set_headersonlyszFeedParser._set_headersonlycCs|jj||jdS)zPush more data into the parser.N)r;r,_call_parse)rr*rrrfeedszFeedParser.feedcCs&y|jWntk
r YnXdS)N)r>r0)rrrrrCszFeedParser._call_parsecCsV|jj|j|j}|js&t|jdkrR|jrRtj	}|j
j|||S)z<Parse all remaining data and return the root message object.	multipart)r;rrC_pop_messager<r#get_content_maintypeZis_multipartrZ!MultipartInvariantViolationDefectr6
handle_defect)rrootdefectrrrrs

zFeedParser.closecCsn|jr|j}n|j|jd}|jr<|jjdkr<|jd|jrR|jdj||jj|||_||_	dS)N)r6zmultipart/digestzmessage/rfc822r&r')
r8r9r6r?get_content_typeZset_default_typer<Zattachrr@)rmsgrrr_new_messages

zFeedParser._new_messagecCs(|jj}|jr|jd|_nd|_|S)Nr&r')r<rr?)rretvalrrrrFs

zFeedParser._pop_messageccs@|jg}xb|jD]X}|tkr(tVqtj|sbtj|s`tj}|jj	|j
||jj|P|j|qW|j
||jrg}x2|jj}|tkrtVq|dkrP|j|qW|j
jtj|dS|j
jdkrx|jjtjx$|jD]}|tkrtVqPqW|j}|jjx&|jj}|tkrFtVq(Pq(Wx&|jj}|tkrntVqPPqPW|dkrP|jj|qWdS|j
jdkrx(|jD]}|tkrtVqPqW|jdS|j
jdkr|j
j}|dkrbtj}|jj	|j
|g}x.|jD]$}|tkr<tVq$|j|q$W|j
jtj|dS|j
jddjdkrtj}|jj	|j
|d	|}tjd
tj |d}	d}
g}d
}d
}
x|jj}|tkrtVq|dkrP|	j|}|r|j!drd}
|j!d}P|
r~|rj|d}t"j#|}|r\|dt$|j!d|d<tj||j
_%d
}
|jj|qxB|jj}|tkrtVq|	j|}|s|jj|PqW|jj|	jx(|jD]}|tkrtVqPqW|j&jdkrb|j&j'}|dkr&d|j&_'n:|dk	rt"j#|}|rt$|j!d}|d||j&_'nD|j&j(}t)|t*rt"j#|}|r|dt$|j!d}||j&_(|jj|j|j
|_&n|
st+|j|qW|
rHtj,}|jj	|j
||j
jtj|g}x$|jD]}|tkrtVqqWtj||j
_'dS|
sjtj-}|jj	|j
|dS|rxdg}ng}x.|jD]$}|tkrtVq|j|qW|r|d}t.j|}|r|t$|j!dd|d<tj||j
_'dSg}x.|jD]$}|tkrtVq|j|qW|j
jtj|dS)Nrzmessage/delivery-statusmessagerEzcontent-transfer-encoding8bit7bitbinaryz--z(?P<sep>z4)(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$TFendlinesepr&r)rQrPrRr'r')/rMr;rheaderREmatchNLCRErZ MissingHeaderBodySeparatorDefectr6rHr?r$r_parse_headersrAr"Zset_payloadEMPTYSTRINGjoinrKrr=rFrrGZget_boundaryZNoBoundaryInMultipartDefectgetlowerZ-InvalidMultipartContentTransferEncodingDefectrecompileescapegroup	NLCRE_eolsearchlenpreambler@epilogueZ_payload
isinstancestrr#ZStartBoundaryNotFoundDefectZCloseBoundaryNotFoundDefect	NLCRE_bol)rZheadersr!rJr.rNrLboundaryZ	separatorZ
boundaryreZcapturing_preamblerdrTZclose_boundary_seenmoZlastlineZeolmorerSZpayload	firstlineZbolmorrrr=sh





































zFeedParser._parsegenc	Cspd}g}xFt|D]8\}}|ddkrV|sJtj|}|jj|j|q|j|q|rx|jj|jj|dg}}|j	dr|dkrt
j|}|r|dt|j
d}|jj|qn:|t|dkr|jj|dStj|}|jjj|q|jd}|dkr*tjd}|jjj|q|dks<td|d|}|g}qW|rl|jj|jj|dS)	Nrrz 	zFrom r&:zMissing header name.z3_parse_headers fed line with no : and no leading WS)	enumeraterZ#FirstHeaderLineIsContinuationDefectr6rHr?rZset_rawZheader_source_parse
startswithrarbrcr`Zset_unixfromr;r$ZMisplacedEnvelopeHeaderDefectZdefectsfindZInvalidHeaderDefectr#)	rr.Z
lastheaderZ	lastvaluelinenor!rJrjirrrrXsH








zFeedParser._parse_headers)N)r2r3r4r5rrrBrDrCrrMrFr=rXrrrrrs

~cs eZdZdZfddZZS)rz(Like FeedParser, but feed accepts bytes.cstj|jdddS)Nasciisurrogateescape)superrDdecode)rr*)	__class__rrrDszBytesFeedParser.feed)r2r3r4r5rD
__classcell__rr)rvrrs)r5__all__r]ZemailrZemail._policybasercollectionsriorr^rWrhraZNLCRE_crackrUrYNLobjectrr
rrrrrr<module>s(




[

OHA YOOOO