bg@LdZddlmZddlmZddlmZddlmZddlmZddlmZgdZ dd l Z dd l Z dd l Z dd l Z dd lZdd lmZmZdd lmZdd lmZdd lmZdd lmcmcmZdZdZe jde j Z!Gdde"Z#Gdde#Z$dZ%Gdde#Z&e'e(e j)dz Z*de*zZ+e#j,Z,d S)z:Classes to generate plain text from a message object tree.)print_function)unicode_literals)division)absolute_import)super)str) GeneratorDecodedGeneratorBytesGeneratorN)StringIOBytesIO)compat32)Header)_has_surrogates_ z^From ceZdZdZddZdZddZdZd Zd Z d Z d Z d Z dZ dZdZeZdZdZdZdZeddZedZdS)r zGenerates output from a Message object tree. This basic generator writes the message to the given file object as plain text. TNc dd|vr |d}|d=nd} ||_||_||_||_dS)Npolicy)_fp _mangle_from_ maxheaderlenr)selfoutfp mangle_from_r _3to2kwargsrs q/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/future/backports/email/generator.py__init__zGenerator.__init__+sO { " "[-BF T\H]H]f *)( c:|j|dSN)rwriterss rr"zGenerator.writeHs qrFc|j|jn|j}|||}|j||j}|j|_||j|_d|_|d|_|j}|j} ||_||_|r[| }|s(dtj tj z}| ||jz| |||_||_dS#||_||_wxYw)azPrint the message object tree rooted at msg to the output file specified when the Generator instance was created. unixfrom is a flag that forces the printing of a Unix From_ delimiter before the first object in the message tree. If the original message has no From_ delimiter, a `standard' one is crafted. By default, this is False to inhibit the printing of any From_ delimiter. Note that for subobjects, no From_ line is printed. linesep specifies the characters used to indicate a new line in the output. The default value is determined by the policy. N)linesepmax_line_lengthz From nobody )rclonerr&_NL_encode _encoded_NL_EMPTY_encoded_EMTPY get_unixfromtimectimer"_write)rmsgunixfromr&rold_gen_policyold_msg_policyufroms rflattenzGenerator.flattenLsC& ${2   \\'\22F   (\\$2C\DDF><<11 "ll2..  ( DKCJ -((**E*TZ -D-DDE 548+,,, KK   (DK'CJJJ)DK'CJ ' ' ' 's +BD;;E cH|||jd|jS)z1Clone this generator with the exact same options.N)r) __class__rr)rfps rr*zGenerator.clone{s-~~b"0"%)[22 2rr)ctSr!)r rs r _new_bufferzGenerator._new_buffers zzrc|Sr!r#s rr,zGenerator._encodesrc|sdS|d}|ddD]D}||d||jE|dd}||t |dt |kr||jdSdS)NTz ) splitlinesr"rstripr+len)rlinesline laststrippeds r _write_lineszGenerator._write_liness  F  &&#2#J ! !D JJt{{6** + + + JJtx Ry''//  <   uRy>>S.. . . JJtx  / .rc^|j} |x|_}||||_n #||_wxYwt|dd}|||n |||j|dS)N_write_headers)rr? _dispatchgetattrrLr"getvalue)rr4oldfpsfpmeths rr3zGenerator._writes !--// /DHs NN3   DHHuDH    s,d33 <    $ $ $ $ DJJJ s||~~&&&&&s 0A A c^|}|}t||fdd}t |d|zd}|3|dd}t |d|zd}||j}||dS)N-r_handle_)get_content_maintypeget_content_subtype UNDERSCOREjoinreplacerN _writeBody)rr4mainsubspecificrRgenerics rrMzGenerator._dispatchs ''))%%''??D#;//77SAAtZ(2D99 <ll3,,G4g!5t<From ) get_payload isinstancer TypeErrortyper_payload get_param set_payloadrfcrer]rJ)rr4payloadrgs r _handle_textzGenerator._handle_texts//## ? F'3'' K9DMMIJJ J 3< ( ( ,mmI..G"34111//++   2hhx11G '"""""rcfg}|}|g}nDt|tr||dSt|ts|g}|D]o}|}||}||d|j| | p| }|sD|j |}||}|||j^|jr!t$d|j} n|j} || ||j|d|z|jz|r-|j|d|D]D} ||jdz|z|jz|j| E||jdz|zdz|j`||j|jr!t$d|j} n|j} || dSdS)NFr5r&rhz--r)rirjrr"listr?r*r9r+appendrO get_boundaryr-rY_make_boundary set_boundarypreamblerrpr]rJrpopepilogue) rr4msgtextssubpartspartr$gboundaryalltextrz body_partr|s r_handle_multipartzGenerator._handle_multiparts??$$  HH # & & " JJx FHd++ " zH * *D  ""A 1 A IIdUDHI = = = OOAJJLL ) ) ) )##%% '&++H55G**733H   X & & & < #! (88Hcl;;<   h ' ' ' JJtx  4(?TX-...  , HNN8<<?? + + +" & &I JJtx$1DH< = = = HNN9 % % % % 48d?X-4555 < # JJtx ! (88Hcl;;<   h ' ' ' ' ' $ #rc|j}|d|_ ||||_dS#||_wxYw)Nrr')rr*r)rr4ps r_handle_multipart_signedz"Generator._handle_multipart_signed/sS Kggag00    " "3 ' ' 'DKKK!DKOOOOs A A c@g}|D]}|}||}||d|j|}||j}|rG|d|jkr6| |j |dd| ||j |j |dS)NFrtrC) rir?r*r9r+rOsplitr-_encoded_EMPTYrvrYrr")rr4blocksrr$rtextrGs r_handle_message_delivery_statusz)Generator._handle_message_delivery_status:sOO%% $ $D  ""A 1 A IIdUDHI = = =::<s rr?zBytesGenerator._new_buffers yyrc,|dSNr)rr#s rr,zBytesGenerator._encodesxx   rc|D]8\}}|j|j||9||jdSr!)rarr"r fold_binaryr+rcs rrLzBytesGenerator._write_headerssbMMOO : :DAq HNN4;221a88 9 9 9 9 48rcB|jdSt|jrX|jjdksH|jr%t d|j|_||jdStt| |dS)N7bitrh) rmrrcte_typerrpr]rJrr rr)rr4r;s rrrzBytesGenerator._handle_texts <  F 3< ( ( 91Ev1M1M! @#xx#,??   cl + + + + + . & & 3 3C 8 8 8 8 8rcRtj|d|Sr)rrrrs rrzBytesGenerator._compile_res z!((7++U333r)rrrrrr"r?r,rLrrr[rr __classcell__)r;s@rr r ~s  NBBB!!! 9 9 9 9 9J44[44444rr zD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c eZdZdZddZdZdS)r zGenerates a text representation of a message. Like the Generator base class, except that non-text parts are substituted with a format string representing the part. TNNcnt|||||t|_dS||_dS)aLike Generator.__init__() except that an additional optional argument is allowed. Walks through all subparts of a message. If the subpart is of main type `text', then it prints the decoded payload of the subpart. Otherwise, fmt is a format string that is used instead of the message payload. fmt is expanded with the following keywords (in %(keyword)s format): type : Full MIME type of the non-text part maintype : Main MIME type of the non-text part subtype : Sub-MIME type of the non-text part filename : Filename of the non-text part description: Description associated with the non-text part encoding : Content transfer encoding of the non-text part The default value for fmt is None, meaning [Non-text (%(type)s) part of message omitted, filename %(filename)s] N)r r_FMTr)rrrrfmts rrzDecodedGenerator.__init__s9, 4 lCCC ;DIIIDIIIrc |D]}|}|dkr&t|d|B|dkrIt|j||||d|dd|d d d z|dS) NrF)decode)file multipartz [no filename]zContent-Descriptionz[no description]zContent-Transfer-Encodingz [no encoding])rlmaintypesubtypefilename descriptionencoding) walkrVprintrirget_content_typerW get_filenameget)rr4rrs rrMzDecodedGenerator._dispatchsHHJJ " "D0022H6!!d&&e&444@@@@@[((di#'#8#8#:#:#'#<#<#>#>#'#;#;#=#=#'#4#4_#E#E#'88,A,>$@$@#'88,G,;$=$= # # ! " " " " " " "r)TrN)rrrrrrMrArrr r sA 8"""""rr rz%%0%dd)-r __future__rrrrfuture.builtinsrr__all__rrr1rwarningsior r "future.backports.email._policybaserfuture.backports.email.headerrfuture.backports.email.utilsrfuture.backports.email.charset backportsemailrg_charsetrXNLrrrpobjectr r rr rFreprr_widthrrxrArrrs  A@%%%%%%''''''&&&&&&!!!!!! = = =  777777000000888888111111111111   rz)R\**[$[$[$[$[$[$[$[$z 3434343434Y343434lN4"4"4"4"4"y4"4"4"p TT#+a- ! !&)r