bgXdZddlmZddlmZddlmZddlmZmZmZddl m Z m Z ddgZ dd l Z dd lmZdd lmZdd lmZe jd Ze jdZe jdZe jdZe jdZdZdZeZGddeZGddeZGddeZd 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)objectrangesuper)implements_iteratorPY3 FeedParserBytesFeedParserN)errors)message)compat32z | | z( | | )z ( | | )\Zz(^(From |[\041-\071\073-\176]{1,}:|[\t ]) cNeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d S) 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. c>d|_g|_g|_d|_dS)NrF)_partial_lines _eofstack_closedselfs r/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/future/backports/email/feedparser.py__init__zBufferedSubFile.__init__9s"   c:|j|dSN)rappend)rpreds rpush_eof_matcherz BufferedSubFile.push_eof_matcherCs d#####rc4|jSr)rpoprs rpop_eof_matcherzBufferedSubFile.pop_eof_matcherFs~!!###rc`|j|jd|_d|_dS)NrT)rr rrrs rclosezBufferedSubFile.closeIs, 4=)))  rc|js|jrdStS|j}|jdddD]*}||r|j|dS+|S)Nr)rr NeedMoreDatar$rr )rlineateofs rreadlinezBufferedSubFile.readlineOs{ | r {  ^DDbD)  EuT{{  ""4(((rr  rcP|tusJ|j|dSr)r*rr rr+s r unreadlinezBufferedSubFile.unreadlineas/<'''' 4     rc|j|zdc}|_t|}||_|jsL|rJ|ddr/|d|z|_g}t t |dzD]/}|||dz||dzdzz0||dS)z$Push some new data into this object.rr) N) r NLCRE_cracksplitr$endswithrlenr pushlines)rdatapartslinesis rpushzBufferedSubFile.pushfs#md2Bdm!!$''   } 6 659+=+=d+C+C 6!IIbMM%))++5DMs5zzQ'' 4 4A LLqseAaCEl2 3 3 3 3 urc0|ddd|jdd<dS)Nr)r)r)rr=s rr:zBufferedSubFile.pushlines}s"+ BQBrc|Srrs r__iter__zBufferedSubFile.__iter__s rcH|}|dkrt|S)Nr)r- StopIterationr/s r__next__zBufferedSubFile.__next__s#}} 2::  rN)__name__ __module__ __qualname____doc__rr"r%r'r-r0r?r:rCrFrBrrrr1s$$$$$$ $!!! .&&&rrcVeZdZdZejfdZdZdZdZ dZ dZ dZ d Z d Zd S) r zA feed-style parser of email.c d|vr |d}|d=nt} |_|_ |jfd_n#t$r d_YnwxYwt _g_tr j _ n j _ d_ d_d_dS)NpolicyrMcdjiS)NrMrNrsrz%FeedParser.__init__..s(DK)@rciSrrBrBrrrPz%FeedParser.__init__..srF)r_factoryrM _factory_kwds TypeErrorr_input _msgstackr _parsegenrF_parsenext_cur_last _headersonly)rrR _3to2kwargsrMs` rrzFeedParser.__init__s { " "[-BF T\H]H]f !   , HDK ( ( ( (!@!@!@!@D   , , ,!+D    ,&''   0..**3DKK..**/DK  !sAAAcd|_dS)NT)r\rs r_set_headersonlyzFeedParser._set_headersonlys rcb|j||dS)zPush more data into the parser.N)rUr? _call_parse)rr;s rfeedzFeedParser.feeds0  rcR |dS#t$rYdSwxYwr)rXrErs rrazFeedParser._call_parses:  KKMMMMM    DD s  &&cN|j||}|jrJ|dkrB|s.tj}|j |||S)z!!!  $ $ & &+ 5 5((** 6=??F K % %dF 3 3 3 rcT|jdi|}|jr2|jdkr|d|jr |jd||j|||_||_dS)Nzmultipart/digestzmessage/rfc822r)rB) rRrSrZget_content_typeset_default_typerVattachr r[)rmsgs r _new_messagezFeedParser._new_messagesdm33d002233 9 333559KKK  !1 2 2 2 > + N2  % %c * * * c"""  rcz|j}|jr|jd|_nd|_|S)Nr))rVr$rZ)rretvals rrfzFeedParser._pop_messages;##%% > r*DIIDI rc#K|g}|jD]}|tur tVt|sit |sMt j}|j |j ||j |n| || ||jrg} |j}|tur tV-|dkrn| |I|j t"|dS|j dkr |jt j|D]}|tur tV|}|j |j}|tur tV- |j}|tur tV- |dkrn|j |dS|j dkr@|D]}|tur tV|dS|j dkr|j }|t j}|j |j |g}|jD]*}|tur tV| |+|j t"|dS|j dddvr3t j}|j |j |d |z}t=jd t=j |zd z} d} g} d } d } |j}|tur tV-|dkrn| |}|r|!d rd} |!d} n| r| rv| d}tD#|}|r.|dtI|!d | d<t"| |j _%d } |j | |j}|tur tV-| |}|s|j |n_|j| j|D]}|tur tV|j&dkru|j&j'}|dkr d|j&_'n|StD#|}|r7tI|!d}|d| |j&_'nt|j&j(}tS|tTrStD#|}|r7|dtI|!d }||j&_(|j||j |_&n| sJ| || rt j+}|j |j ||j t"| g}|jD]}|tur tVt"||j _'dS| s5t j,}|j |j |dS| rdg}ng}|jD]*}|tur tV| |+|rQ|d}tZ|}|r-|tI|!dd|d<t"||j _'dSg}|jD]*}|tur tV| |+|j t"|dS)NTrzmessage/delivery-statusrrezcontent-transfer-encoding8bit)7bitrvbinaryz--z(?Pz4)(?P--)?(?P[ \t]*)(?P\r\n|\r|\n)?$Fendlinesepr)r).rrrUr*headerREmatchNLCREr MissingHeaderBodySeparatorDefectrMrjrZr0r _parse_headersr\r- set_payload EMPTYSTRINGjoinrnr"rWrfr%rg get_boundaryNoBoundaryInMultipartDefectgetlower-InvalidMultipartContentTransferEncodingDefectrecompileescapegroup NLCRE_eolsearchr9preambler[epilogue_payload isinstancestrStartBoundaryNotFoundDefectCloseBoundaryNotFoundDefect NLCRE_bol)rheadersr+rlr=rtrqboundary separator boundaryrecapturing_preamblerrzclose_boundary_seenmolastlineeolmorrypayload firstlinebolmos rrWzFeedParser._parsegens  K ! !D|##"""">>$'' {{4((1#DFFFK--di@@@K**4000 NN4  G$$$   E #{++--<''&&&&2:: T""" # I ! !+"2"25"9"9 : : : F 9 % % ' '+D D D  - ,,U[999"nn..F--**** '')) ++--- ;//11D|++**** ;//11D|++**** 2:: &&t,,,? -@ F 9 ) ) + +y 8 8..**  \))&&&&       F 9 ) ) + +{ : :y--//H  ;== ))$)V<<< K''D|++**** LL&&&& %%k&6&6u&=&=>>> 96BBHHJJ566MOO ))$)V<<< xIRYy111GHIIJ"& HG"' O *{++--<''&&&&2::%%d++G* xx.2+"$((9"5"5) !#L(0|H$-$4$4X$>$>E$O/78M#ekk!nn:M:M9M8M/N 1<1A1A(1K1KDI.-2* ..t444 "#{3355<//"....$'--d33!" K224888!"K001ABBB"&.."2"2!\11"....$ z6688KGG#':#6#r>>26DJ//%1!*!1!1(!;!;B!F&)"((1++&6&66>uuo 3"&*"5%gs33>!*!1!1'!:!:B!>*12DC 4D4D3D2D*E6= 3K//111%%'''"&DJJ.---OOD)))_O *f" ;== ))$)V<<< %%k&6&6x&@&@AAA K!!D|++**** ,&1%5%5h%?%? "' ;== ))$)V<<< 4  & &<''&&&&%%%% B$QK ! 22B"+C A,?,?,@,@"AHQK!,!1!1(!;!;DI  FK  D|##"""" LL     k..u5566666rcd}g}t|D]\}}|ddvrM|s5tj|}|j|j|G||]|r+|jj|j|dg}}| dr|dkrct |}|r+|dt| d }|j||t|dz kr|j|dStj|}|jj|p|d}|dks Jd|d|}|g}|r)|jj|j|dSdS)Nrrz zFrom r5:z3_parse_headers fed line with no : and no leading WS) enumerater #FirstHeaderLineIsContinuationDefectrMrjrZr set_rawheader_source_parse startswithrrr9r set_unixfromrUr0MisplacedEnvelopeHeaderDefectdefectsfind) rr= lastheader lastvaluelinenor+rlrr>s rrzFeedParser._parse_headerss  %e,,* * LFDAw%!$GMMFK--di@@@  &&& /! !4;#B#B9#M#MNN(*BI w'' Q;;"))$//B8#$6c"((1++&6&6%6$67I**4000s5zzA~--K**4000FF$A$GGFI%,,V444 #AQ333M333bqbJII  K DI t{>>yII J J J J K KrN)rGrHrIrJrMessagerr_rbrar'rrrfrWrrBrrr r s'' '"""":!!!    {7{7{7z1K1K1K1K1Krc"eZdZdZfdZxZS)r z(Like FeedParser, but feed accepts bytes.crt|dddS)Nasciisurrogateescape)rrbdecode)rr; __class__s rrbzBytesFeedParser.feed s.  T[[*;<<=====r)rGrHrIrJrb __classcell__)rs@rr r s>22>>>>>>>>>r)rJ __future__rrrfuture.builtinsrrr future.utilsr r __all__rfuture.backports.emailr r"future.backports.email._policybaserrr}rrr6r{rNLr*rr r rBrrrs  ('''''&&&&&&000000000011111111 * + ))))))******777777 <   BJ~ & & BJ' ( ( bj((  2:A B B  vxx WWWWWfWWWt{K{K{K{K{K{K{K{K| >>>>>j>>>>>r