o !QçdäNã@sÈ gd¢ZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z dZ dZ e d¡Ze d ej¡ZGd d „d ƒZGd d „d eƒZdZGdd„deƒZeeejdƒƒZdeZejZdS))Ú GeneratorÚDecodedGeneratorÚBytesGeneratoréN)Údeepcopy)ÚStringIOÚBytesIO)Ú_has_surrogatesÚ_Ú z \r\n|\r|\nz^From c@s®eZdZ d&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©ÚpolicycCs8 |dur|dur dn|j}||_||_||_||_dS)NT)Ú mangle_from_Ú_fpÚ _mangle_from_Ú maxheaderlenr )ÚselfÚoutfpr rr ©rú6/opt/alt/python310/lib64/python3.10/email/generator.pyÚ__init__$s zGenerator.__init__cCs|j |¡dS©N)rÚwrite©rÚsrrrrDszGenerator.writeFcCsä |jdur |jn|j}|dur|j|d}|jdur"|j|jd}|j|_| |j¡|_d|_| |j¡|_|j}|j}z-||_||_|r]|  ¡}|sUdt   t   ¡¡}|  ||j¡|  |¡W||_||_dS||_||_w)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ÚflattenHs2    ÿzGenerator.flattencCs |j||jd|jdS©Nr )Ú __class__rr )rÚfprrrrys ýzGenerator.clonecCótƒSr)r©rrrrÚ _new_bufferszGenerator._new_buffercCs|Srrrrrrr‘szGenerator._encodecCsX|sdSt |¡}|dd…D] }| |¡| |j¡q|dr*| |d¡dSdS)Néÿÿÿÿ)ÚNLCREÚsplitrr)rÚlinesÚlinerrrÚ _write_lines•s  ÿzGenerator._write_linescCsÐ|j}zd|_| ¡|_}| |¡W||_|j}|`n ||_|j}|`w|rJt|ƒ}| d¡dur:|d|d<n| d|d¡| d|d¡t|ddƒ}|durZ| |¡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ƒ}|dur4| dd¡}t|d|dƒ}|dur4|j}||ƒdS)Nú-r Z_handle_)Úget_content_maintypeÚget_content_subtypeÚ UNDERSCOREÚjoinÚreplacer<Ú _writeBody)rr%ÚmainÚsubZspecificr>Zgenericrrrr:Ìs  zGenerator._dispatchcCs6| ¡D]\}}| |j ||¡¡q| |j¡dSr)Ú raw_itemsrr Zfoldr©rr%ÚhÚvrrrr8àszGenerator._write_headerscCsž| ¡}|dur dSt|tƒstdt|ƒƒ‚t|jƒr?| d¡}|dur?t|ƒ}|d=|  ||¡| ¡}|d|df|_ |j rHt   d|¡}| |¡dS)Nzstring payload expected: %sÚcharsetr4r6ú>From )Ú get_payloadÚ isinstanceÚstrÚ TypeErrorÚtyperÚ_payloadZ get_paramrZ set_payloadr9rÚfcrerGr3)rr%ÚpayloadrLrrrÚ _handle_textês$    ÿ zGenerator._handle_textc Cs–g}| ¡}|dur g}nt|tƒr| |¡dSt|tƒs!|g}|D]}| ¡}| |¡}|j|d|jd|  |  ¡¡q#|  ¡}|sU|j   |¡}| |¡}| |¡|jdurs|jret 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} | | ¡dSdS)NF©r&rrMz--r)rNrOrPrÚlistr-rr'rÚappendr=Z get_boundaryr rCÚ_make_boundaryZ set_boundaryÚpreamblerrTrGr3rÚpopÚepilogue) rr%ZmsgtextsZsubpartsÚpartrÚgÚboundaryZalltextr[Z body_partr]rrrÚ_handle_multipartsL           ûzGenerator._handle_multipartcCs4|j}|jdd|_z | |¡W||_dS||_w)Nrr)r rra)rr%ÚprrrÚ_handle_multipart_signed<s  z"Generator._handle_multipart_signedcCsšg}| ¡D]:}| ¡}| |¡}|j|d|jd| ¡}| |j¡}|r;|d|jkr;|  |j  |dd…¡¡q|  |¡q|j   |j  |¡¡dS)NFrWr.) rNr-rr'rr=r0r r!rYrCrr)rr%Zblocksr^rr_Útextr1rrrÚ_handle_message_delivery_statusGs    z)Generator._handle_message_delivery_statuscCs^| ¡}| |¡}|j}t|tƒr"|j| d¡d|jd| ¡}n|  |¡}|j   |¡dS)NrFrW) r-rrSrOrXr'rNrr=rrr)rr%rr_rUrrrÚ_handle_message\s    zGenerator._handle_messagecCsxt tj¡}dt|d}|dur|S|}d} | dt |¡dtj¡}|  |¡s/ |S|dt |ƒ}|d7}q) Nz===============z==rTz^--z(--)?$Ú.r7) ÚrandomZ randrangeÚsysÚmaxsizeÚ_fmtÚ _compile_reÚreÚescapeÚ MULTILINEÚsearchrP)ÚclsrdÚtokenr`ÚbZcounterZcrerrrrZus  þûzGenerator._make_boundarycCs t ||¡Sr)rmÚcompile©rqrÚflagsrrrrl‡s zGenerator._compile_re)NN)FNr)Ú__name__Ú __module__Ú __qualname__rrr'rr-rr3r$r:r8rVrErarcrerfÚ classmethodrZrlrrrrrs0  ÿ 1' :  rcsNeZdZ dd„Zdd„Zdd„Zdd„Z‡fd d „ZeZe d d „ƒZ ‡Z S) rcCs|j | dd¡¡dS)NÚasciiÚsurrogateescape)rrÚencoderrrrr™szBytesGenerator.writecCr+r)rr,rrrr-œszBytesGenerator._new_buffercCs | d¡S©Nr{)r}rrrrrŸs zBytesGenerator._encodecCs8| ¡D]\}}|j |j ||¡¡q| |j¡dSr)rHrrr Z fold_binaryrrIrrrr8¢szBytesGenerator._write_headerscs^|jdurdSt|jƒr%|jjdks%|jrt d|j¡|_| |j¡dStt |ƒ  |¡dS)NZ7bitrM) rSrr Zcte_typerrTrGr3ÚsuperrrV)rr%©r)rrrVªs zBytesGenerator._handle_textcCst | d¡|¡Sr~)rmrtr}rurrrrl¹szBytesGenerator._compile_re) rwrxryrr-rr8rVrErzrlÚ __classcell__rrr€rrŒs   rzD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s&eZdZ dddœdd„Zdd„ZdS)rNr cCs2 tj|||||d|durt|_dS||_dSr()rrÚ_FMTrk)rrr rZfmtr rrrrÇs ÿ  zDecodedGenerator.__init__c Cs„| ¡D];}| ¡}|dkrt|jdd|dq|dkrqt|j| ¡| ¡| ¡| d¡| dd¡| d d ¡d œ|dqdS) NrdF)Údecode)ÚfileZ multipartz [no filename]zContent-Descriptionz[no description]r5z [no encoding])rRÚmaintypeZsubtypeÚfilenameÚ descriptionÚencoding) Úwalkr@ÚprintrNrkZget_content_typerAÚ get_filenamer;)rr%r^r…rrrr:ås* ÿÿù ÷øzDecodedGenerator._dispatch)NNN)rwrxryrr:rrrrrÁs  ÿ rr7z%%0%dd)Ú__all__rmrir"rhÚcopyrÚiorrZ email.utilsrrBÚNLrtr/rorTrrr‚rÚlenÚreprrjZ_widthrkrZrrrrÚs,   t3;