Ñò §ÚêLc @súdZddgZddkZddkZddkZddkZddkZddklZddk l Z dZ dZ ei d eiƒZd „Zdfd „ƒYZd Zdefd „ƒYZeeeidƒƒZdeZed„ZdS(s:Classes to generate plain text from a message object tree.t GeneratortDecodedGeneratoriÿÿÿÿN(tStringIO(tHeadert_s s^From cCs@t|tƒo,yt|dƒWq<tj otSXntS(Nsus-ascii(t isinstancetstrtunicodet UnicodeErrortTruetFalse(ts((s'/usr/lib64/python2.6/email/generator.pyt _is8bitstrings  cBs‰eZdZedd„Zd„Zed„Zd„Zd„Z d„Z d„Z d „Z e Z d „Zd „Zd „Zd „ZRS(sŠGenerates output from a Message object tree. This basic generator writes the message to the given file object as plain text. iNcCs||_||_||_dS(sáCreate the generator for message flattening. outfp is the output file-like object for writing the message to. It must have a write() method. Optional mangle_from_ is a flag that, when True (the default), escapes From_ lines in the body of the message by putting a `>' in front of them. Optional maxheaderlen specifies the longest length for a non-continued header. When a header line is longer (in characters, with tabs expanded to 8 spaces) than maxheaderlen, the header will split as defined in the Header class. Set maxheaderlen to zero to disable header wrapping. The default is 78, as recommended (but not required) by RFC 2822. N(t_fpt _mangle_from_t _maxheaderlen(tselftoutfpt mangle_from_t maxheaderlen((s'/usr/lib64/python2.6/email/generator.pyt__init__*s  cCs|ii|ƒdS(N(R twrite(RR ((s'/usr/lib64/python2.6/email/generator.pyR?scCsY|oA|iƒ}|pdtitiƒƒ}n|i|IJn|i|ƒdS(sìPrint 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. s From nobody N(t get_unixfromttimetctimeR t_write(Rtmsgtunixfromtufrom((s'/usr/lib64/python2.6/email/generator.pytflattenCs  cCs|i||i|iƒS(s1Clone this generator with the exact same options.(t __class__RR(Rtfp((s'/usr/lib64/python2.6/email/generator.pytcloneUscCs‹|i}z!tƒ|_}|i|ƒWd||_Xt|ddƒ}|djo|i|ƒn ||ƒ|ii|iƒƒdS(Nt_write_headers(R Rt _dispatchtgetattrtNoneR!Rtgetvalue(RRtoldfptsfptmeth((s'/usr/lib64/python2.6/email/generator.pyR]s    cCs°|iƒ}|iƒ}ti||fƒiddƒ}t|d|dƒ}|djoF|iddƒ}t|d|dƒ}|djo |i}q¢n||ƒdS(Nt-Rt_handle_(tget_content_maintypetget_content_subtypet UNDERSCOREtjointreplaceR#R$t _writeBody(RRtmaintsubtspecificR(tgeneric((s'/usr/lib64/python2.6/email/generator.pyR"xs  !  c CsÍx¿|iƒD]±\}}|id|I|idjo|i|IJq t|tƒo|i|iƒIJq t|ƒo|i|IJq |it|d|id|ddƒiƒIJq W|iJdS(Ns%s:it maxlinelent header_nametcontinuation_wss (titemsR RRRtencodeR (RRthtv((s'/usr/lib64/python2.6/email/generator.pyR!Œs   cCs||iƒ}|djodSt|tƒptdt|ƒƒ‚n|iotid|ƒ}n|i i |ƒdS(Nsstring payload expected: %ss>From ( t get_payloadR$Rt basestringt TypeErrorttypeRtfcreR2R R(RRtpayload((s'/usr/lib64/python2.6/email/generator.pyt _handle_text©s   c CsÚg}|iƒ}|djo g}nCt|tƒo|ii|ƒdSt|tƒp |g}nxL|D]D}tƒ}|i|ƒ}|i |dt ƒ|i |i ƒƒqrWt i|ƒ}|idt|ƒƒ}|iƒ|jo|i|ƒn|idj o|i|iIJn|id|IJ|o|ii|idƒƒnx/|D]'} |id|IJ|ii| ƒqeW|iid|dƒ|idj o|iJ|ii|iƒndS(NRtfailobjs--is --(R<R$RR=R RtlistRR RR tappendR%tNLR.t get_boundaryt_make_boundaryt set_boundarytpreambletpoptepilogue( RRtmsgtextstsubpartstpartR tgtalltexttboundaryt body_part((s'/usr/lib64/python2.6/email/generator.pyt_handle_multipart¶s@     cCs4|i}zd|_|i|ƒWd||_XdS(Ni(RRT(RRtold_maxheaderlen((s'/usr/lib64/python2.6/email/generator.pyt_handle_multipart_signedís   cCsÃg}x|iƒD]}tƒ}|i|ƒ}|i|dtƒ|iƒ}|idƒ}|o/|ddjo|iti |d ƒƒq|i|ƒqW|i i ti |ƒƒdS(NRs iÿÿÿÿt( R<RR RR R%tsplitRERFR.R R(RRtblocksROR RPttexttlines((s'/usr/lib64/python2.6/email/generator.pyt_handle_message_delivery_statusøs   cCsttƒ}|i|ƒ}|iƒ}t|tƒo,|i|idƒdtƒ|iƒ}n|ii |ƒdS(NiR( RR R<RRDRR R%R R(RRR RPRA((s'/usr/lib64/python2.6/email/generator.pyt_handle_message s  (t__name__t __module__t__doc__R RRR RR RR"R!RBR0RTRVR\R](((s'/usr/lib64/python2.6/email/generator.pyR s        7 sD[Non-text (%(type)s) part of message omitted, filename %(filename)s]cBs)eZdZeddd„Zd„ZRS(s±Generator 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. iNcCs=ti||||ƒ|djo t|_n ||_dS(sŒLike 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(RRR$t_FMTt_fmt(RRRRtfmt((s'/usr/lib64/python2.6/email/generator.pyR)s  cCsÍxÆ|iƒD]¸}|iƒ}|djo||idtƒIJq |djoq ||ih|iƒd6|iƒd6|iƒd6|idƒd6|id d ƒd 6|id d ƒd6IJq WdS(NRZtdecodet multipartR?tmaintypetsubtypes [no filename]tfilenamesContent-Descriptions[no description]t descriptionsContent-Transfer-Encodings [no encoding]tencoding( twalkR+R<R Rbtget_content_typeR,t get_filenametget(RRRORf((s'/usr/lib64/python2.6/email/generator.pyR"Es            N(R^R_R`R R$RR"(((s'/usr/lib64/python2.6/email/generator.pyR#sis%%0%ddcCs®titiƒ}d t|d}|djo|S|}d}xeto]tidti |ƒdti ƒ}|i |ƒpPn|dt |ƒ}|d7}qEW|S( Nt=is==is^--s(--)?$t.is===============( trandomt randrangetsystmaxintRbR$R tretcompiletescapet MULTILINEtsearchR(RZttokenRRtbtcountertcre((s'/usr/lib64/python2.6/email/generator.pyRH_s &(R`t__all__RuRsRRqtwarningst cStringIORt email.headerRR-RFRvRxR@R RRaRtlentreprRtt_widthRbR$RH(((s'/usr/lib64/python2.6/email/generator.pyts&       ÿ9