a ÕDOgPQã@sÜgd¢ZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z ddl m Z dZdZe d ¡Ze d ej¡Ze d ¡ZGd d „d ƒZGdd„deƒZdZGdd„deƒZeeejdƒƒZdeZejZdS))Ú GeneratorÚDecodedGeneratorÚBytesGeneratoréN)Údeepcopy)ÚStringIOÚBytesIO)Ú_has_surrogates)ÚHeaderWriteErrorÚ_Ú z \r\n|\r|\nz^From z\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]c@s¬eZdZd&ddœdd„Zdd„Zd'dd „Zd d „Zd d „Zdd„Zdd„Z dd„Z dd„Z dd„Z dd„Z e Zdd„Zdd„Zdd„Zd d!„Zed(d"d#„ƒZed$d%„ƒZdS))rN©ÚpolicycCs6|dur|durdn|j}||_||_||_||_dS)NT)Ú mangle_from_Ú_fpÚ _mangle_from_Ú maxheaderlenr )ÚselfÚoutfprrr ©rú4/opt/alt/python39/lib64/python3.9/email/generator.pyÚ__init__&s zGenerator.__init__cCs|j |¡dS©N)rÚwrite©rÚsrrrrFszGenerator.writeFcCsä|jdur|jn|j}|dur*|j|d}|jdurB|j|jd}|j|_| |j¡|_d|_| |j¡|_|j}|j}zX||_||_|r¸|  ¡}|s¨dt   t   ¡¡}|  ||j¡|  |¡W||_||_n||_||_0dS)N)Úlinesep©Zmax_line_lengthÚz From nobody )r ÚclonerrÚ_NLÚ_encodeÚ _encoded_NLZ_EMPTYÚ_encoded_EMPTYZ get_unixfromÚtimeÚctimerÚ_write)rÚmsgÚunixfromrr Zold_gen_policyZold_msg_policyZufromrrrÚflattenJs0   ÿzGenerator.flattencCs|j||jd|jdS©Nr )Ú __class__rr )rÚfprrrr{s ýzGenerator.clonecCstƒSr)r©rrrrÚ _new_bufferszGenerator._new_buffercCs|Srrrrrrr “szGenerator._encodecCsT|sdSt |¡}|dd…D]}| |¡| |j¡q|drP| |d¡dS)Néÿÿÿÿ)ÚNLCREÚsplitrr)rÚlinesÚlinerrrÚ _write_lines—s  zGenerator._write_linescCsÐ|j}z2d|_| ¡|_}| |¡W||_|j}|`n||_|j}|`0|r”t|ƒ}| d¡durt|d|d<n| d|d¡| d|d¡t|ddƒ}|dur´| |¡n||ƒ|j  |  ¡¡dS)Núcontent-transfer-encodingrúContent-Transfer-Encodingú content-typeéÚ_write_headers) rÚ _munge_cter-Ú _dispatchrÚgetZreplace_headerÚgetattrr8rÚgetvalue)rr&ZoldfpZsfpZ munge_cteÚmethrrrr%§s,  þ  zGenerator._writecCst| ¡}| ¡}t ||f¡ dd¡}t|d|dƒ}|durh| dd¡}t|d|dƒ}|durh|j}||ƒdS)Nú-r Z_handle_)Úget_content_maintypeÚget_content_subtypeÚ UNDERSCOREÚjoinÚreplacer<Ú _writeBody)rr&ÚmainÚsubZspecificr>Zgenericrrrr:Îs zGenerator._dispatchcCsŠ| ¡D]p\}}|j ||¡}|jjrn|jj}| |jj¡sPtd|›d|›ƒ‚t |  |¡¡rntd|›ƒ‚|  |¡q|  |j ¡dS)Nz folded header does not end with z: z folded header contains newline: ) Ú raw_itemsr ZfoldZverify_generated_headersrÚendswithr ÚNEWLINE_WITHOUT_FWSPÚsearchÚ removesuffixrr)rr&ÚhÚvZfoldedrrrrr8âsÿÿ zGenerator._write_headerscCsž| ¡}|durdSt|tƒs.tdt|ƒƒ‚t|jƒr~| d¡}|dur~t|ƒ}|d=|  ||¡| ¡}|d|df|_ |j rt   d|¡}| |¡dS)Nzstring payload expected: %sÚcharsetr4r6ú>From )Ú get_payloadÚ isinstanceÚstrÚ TypeErrorÚtyperÚ_payloadZ get_paramrZ set_payloadr9rÚfcrerGr3)rr&ÚpayloadrOrrrÚ _handle_textõs$    ÿ zGenerator._handle_textc Csšg}| ¡}|durg}n(t|tƒr2| |¡dSt|tƒsB|g}|D]6}| ¡}| |¡}|j|d|jd|  |  ¡¡qF|  ¡}|sª|j   |¡}| |¡}| |¡|jduræ|jrÊt d|j¡} n|j} | | ¡| |j¡| d||j¡|r|j | d¡¡|D],} | |jd||j¡|j | ¡q| |jd|d|j¡|jdur–|jr†t d|j¡} n|j} | | ¡dS)NF©r'rrPz--r)rQrRrSrÚlistr-rr(rÚappendr=Z get_boundaryr!rCÚ_make_boundaryZ set_boundaryÚpreamblerrWrGr3rÚpopÚepilogue) rr&ZmsgtextsZsubpartsÚpartrÚgÚboundaryZalltextr^Z body_partr`rrrÚ_handle_multipart sJ           zGenerator._handle_multipartcCs6|j}|jdd|_z| |¡W||_n||_0dS)Nrr)r rrd)rr&ÚprrrÚ_handle_multipart_signedGs  z"Generator._handle_multipart_signedcCsšg}| ¡D]t}| ¡}| |¡}|j|d|jd| ¡}| |j¡}|rv|d|jkrv|  |j  |dd…¡¡q |  |¡q |j   |j  |¡¡dS)NFrZr.) rQr-rr(rr=r0r!r"r\rCrr)rr&ZblocksrarrbÚtextr1rrrÚ_handle_message_delivery_statusRs    z)Generator._handle_message_delivery_statuscCs^| ¡}| |¡}|j}t|tƒrD|j| d¡d|jd| ¡}n |  |¡}|j   |¡dS)NrFrZ) r-rrVrRr[r(rQrr=r rr)rr&rrbrXrrrÚ_handle_messagegs    zGenerator._handle_messagecCsvt tj¡}dt|d}|dur(|S|}d}| dt |¡dtj¡}|  |¡sXqr|dt |ƒ}|d7}q0|S)Nz===============z==rz^--z(--)?$Ú.r7) ÚrandomZ randrangeÚsysÚmaxsizeÚ_fmtÚ _compile_reÚreÚescapeÚ MULTILINErKrS)ÚclsrgÚtokenrcÚbZcounterZcrerrrr]€s   zGenerator._make_boundarycCs t ||¡Sr)rpÚcompile©rsrÚflagsrrrro’szGenerator._compile_re)NN)FN)N)Ú__name__Ú __module__Ú __qualname__rrr(rr-r r3r%r:r8rYrErdrfrhriÚ classmethodr]rorrrrrs, ÿ  1':  rcsLeZdZdd„Zdd„Zdd„Zdd„Z‡fd d „ZeZe d d „ƒZ ‡Z S) rcCs|j | dd¡¡dS)NÚasciiÚsurrogateescape)rrÚencoderrrrr¤szBytesGenerator.writecCstƒSr)rr,rrrr-§szBytesGenerator._new_buffercCs | d¡S©Nr})rrrrrr ªszBytesGenerator._encodecCs8| ¡D]\}}|j |j ||¡¡q| |j¡dSr)rHrrr Z fold_binaryr)rr&rMrNrrrr8­szBytesGenerator._write_headerscs\|jdurdSt|jƒrH|jjdksH|jr:t d|j¡|_| |j¡ntt |ƒ  |¡dS)NZ7bitrP) rVrr Zcte_typerrWrGr3ÚsuperrrY)rr&©r*rrrYµs zBytesGenerator._handle_textcCst | d¡|¡Sr€)rprvrrwrrrroÄszBytesGenerator._compile_re) ryrzr{rr-r r8rYrEr|roÚ __classcell__rrr‚rr—s  rzD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s$eZdZdddœdd„Zdd„ZdS)rNr cCs.tj|||||d|dur$t|_n||_dSr))rrÚ_FMTrn)rrrrZfmtr rrrrÒs  ÿzDecodedGenerator.__init__c Cs„| ¡D]v}| ¡}|dkr2t|jdd|dq|dkrs,     }3;