Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/future/backports/email/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@`sVdZddlmZddlmZddlmZddlmZmZmZddl m
Z
mZddgZdd l
Z
dd
lmZddlmZddlmZe
jd
�Ze
jd�Ze
jd�Ze
jd�Ze
jd�ZdZdZe�Zdefd��YZdefd��YZdefd��YZd S(uFeedParser
- 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.
i(tunicode_literals(tdivision(tabsolute_import(tobjecttrangetsuper(timplements_iteratortPY3u
FeedParseruBytesFeedParserN(terrors(tmessage(tcompat32u
|
|
u(
|
|
)u
(
|
|
)\Zu(^(From |[\041-\071\073-\176]{1,}:|[\t ])uu
tBufferedSubFilecB`sheZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�ZRS(ukA 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.
cC`s(d|_g|_g|_t|_dS(Nu(t_partialt_linest _eofstacktFalset_closed(tself((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyt__init__9s cC`s|jj|�dS(N(Rtappend(Rtpred((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pytpush_eof_matcherCscC`s
|jj�S(N(Rtpop(R((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pytpop_eof_matcherFscC`s)|jj|j�d|_t|_dS(Nu(R
RRtTrueR(R((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pytcloseIs cC`sn|js|jrdStS|jj�}x>|jddd�D]&}||�r@|jj|�dSq@W|S(Nui����(R
RtNeedMoreDataRRR(Rtlinetateof((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pytreadlineOs cC`s|jj|�dS(N(R
R(RR((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyt
unreadlineascC`s�|j|d}|_tj|�}|j�|_|jrw|rw|djd�rw|jd�|j�|_ng}xCtt|�d�D]+}|j||d||dd�q�W|j|�dS(u$Push
some new data into this
object.ui����u
i����iiN( RtNLCRE_cracktsplitRtendswithRtlenRt pushlines(Rtdatatpartstlinesti((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pytpushfs#)cC`s|ddd�|jd*dS(Ni����i(R
(RR&((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyR#}scC`s|S(N((R((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyt__iter__�scC`s%|j�}|dkr!t�n|S(Nu(Rt
StopIteration(RR((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyt__next__�s (
t__name__t
__module__t__doc__RRRRRRR(R#R)R+(((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyR1s
t
FeedParsercB`seeZdZejd�Zd�Zd�Zd�Zd�Z d�Z
d�Zd�Zd �Z
RS(
uA feed-style parser of email.c`s�d|kr
|d}|d=nt}|�_|�_y&|d�j��fd��_Wntk
r}d��_nXt��_g�_tr��j �j
�_n�j �j�_d�_d�_t�_dS(Nupolicytpolicyc`si�jd6S(Nupolicy(R0((R(sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyt<lambda>�scS`siS(N((((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyR1�s(R
t_factoryR0t
_factory_kwdst TypeErrorRt_inputt _msgstackRt _parsegenR+t_parsetnexttNonet_curt_lastRt_headersonly(RR2t_3to2kwargsR0((RsE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyR�s&
cC`s
t|_dS(N(RR=(R((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyt_set_headersonly�scC`s|jj|�|j�dS(uPush
more data into the
parser.N(R5R(t_call_parse(RR$((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pytfeed�scC`s&y|j�Wntk
r!nXdS(N(R8R*(R((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyR@�s
cC`sh|jj�|j�|j�}|j�dkrd|j�rdtj�}|jj ||�n|S(u<Parse
all remaining data and return the root message object.u multipart(
R5RR@t_pop_messagetget_content_maintypetis_multipartRt!MultipartInvariantViolationDefectR0t
handle_defect(Rtroottdefect((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyR�s
cC`s�|j|j��}|jrC|jj�dkrC|jd�n|jrc|jdj|�n|jj|�||_||_dS(Numultipart/digestumessage/rfc822i����( R2R3R;tget_content_typetset_default_typeR6tattachRR<(Rtmsg((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyt_new_message�s cC`s8|jj�}|jr+|jd|_n d|_|S(Ni����(R6RR;R:(Rtretval((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyRB�s
cc`s4|j�g}x�|jD]�}|tkr7tVqntj|�s�tj|�s�tj�}|jj |j
|�|jj|�nPn|j|�qW|j
|�|jr(g}xMtr
|jj�}|tkr�tVq�n|dkr�Pn|j|�q�W|j
jtj|��dS|j
j�dkr1x�tr,|jjtj�x,|j�D]}|tkr�tVqfnPqfW|j�}|jj�x1tr�|jj�}|tkr�tVq�nPq�Wx1tr|jj�}|tkrtVq�nPq�W|dkrPn|jj|�q@WdS|j
j�dkr�x,|j�D]}|tkrptVqSnPqSW|j�dS|j
j�dkr�|j
j�}|dkr0tj�}|jj |j
|�g}x5|jD]*}|tkrtVq�n|j|�q�W|j
jtj|��dS|j
jdd�j�dkrvtj�}|jj |j
|�nd |}t j!d
t j"|�d�} t}
g}t#}t#}
x�trp|jj�}|tkr�tVq�n|dkr�Pn| j|�}|r`|j$d�r4t}
|j$d
�}Pn|
r�|r�|d}t%j&|�}|r�|t'|j$d��
|d<ntj|�|j
_(nt#}
|jj|�q�nxYtr|jj�}|tkr�tVq�n| j|�}|s�|jj|�Pq�q�W|jj| j�x,|j�D]}|tkrMtVq0nPq0W|j)j�dkr�|j)j*}|dkr�d|j)_*q:|dk r:t%j&|�}|r�t'|j$d��}||
|j)_*q�q:n\|j)j+}t,|t-�r:t%j&|�}|r:|t'|j$d��
}||j)_+q:n|jj�|j�|j
|_)q�|j|�q�W|
r�tj.�}|jj |j
|�|j
jtj|��g}x(|jD]}|tkr�tVq�q�q�Wtj|�|j
_*dS|
s(tj/�}|jj |j
|�dS|r:dg}ng}x5|jD]*}|tkrgtVqJn|j|�qJW|r�|d}t0j|�}|r�|t'|j$d��|d<q�ntj|�|j
_*dSg}x5|jD]*}|tkrtVq�n|j|�q�W|j
jtj|��dS(Nuumessage/delivery-statusumessageu multipartucontent-transfer-encodingu8bitu7bitubinaryu--u(?P<sep>u4)(?P<end>--)?(?P<ws>[
\t]*)(?P<linesep>\r\n|\r|\n)?$uendulinesepi����i(u7bitu8bitubinary(1RMR5RtheaderREtmatchtNLCRERt
MissingHeaderBodySeparatorDefectR0RFR;RRt_parse_headersR=RRtset_payloadtEMPTYSTRINGtjoinRIRR7RBRRCtget_boundaryR:tNoBoundaryInMultipartDefecttgettlowert-InvalidMultipartContentTransferEncodingDefecttretcompiletescapeRtgroupt NLCRE_eoltsearchR"tpreambleR<tepiloguet_payloadt
isinstancetstrtStartBoundaryNotFoundDefecttCloseBoundaryNotFoundDefectt NLCRE_bol(RtheadersRRHR&RNRLtboundaryt separatort
boundaryretcapturing_preambleRbtlineseptclose_boundary_seentmotlastlineteolmoRctendtpayloadt firstlinetbolmo((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyR7�sf
!
#c C`s�d}g}xwt|�D]i\}}|ddkry|sftj|�}|jj|j|�qn|j|�qn|r�|jj|jj|��dg}}n|j d�r`|dkrt
j|�}|r�|t|j
d��
}n|jj|�qq`|t|�dkr8|jj|�dStj|�}|jjj|�qn|jd�}||
}|g}qW|r�|jj|jj|��ndS(Nuiu uFrom
iu:(t enumerateRt#FirstHeaderLineIsContinuationDefectR0RFR;Rtset_rawtheader_source_parset
startswithR`RaR"R_tset_unixfromR5RtMisplacedEnvelopeHeaderDefecttdefectstfind( RR&t
lastheadert lastvaluetlinenoRRHRqR'((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyRS�s>
(R,R-R.R tMessageRR?RAR@RRMRBR7RS(((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyR/�s
�tBytesFeedParsercB`seZdZd�ZRS(u(Like FeedParser, but feed
accepts bytes.cC`s
t�j|jdd��dS(Nuasciiusurrogateescape(RRAtdecode(RR$((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyRAs(R,R-R.RA(((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyR� s(R.t
__future__RRRtfuture.builtinsRRRtfuture.utilsRRt__all__R\tfuture.backports.emailRR t"future.backports.email._policybaseR
R]RQRiR`RRORUtNLRRR/R�(((sE/usr/lib/python2.7/site-packages/future/backports/email/feedparser.pyt<module>s, Z�