;ò &± ?c@sdZdkZdkZdkZdkZdkZdklZlZdk l Z dk l Z dk lZydklZWn ej odklZnXyeefWnej odZdZnXd Zd Zd Zd Zd ZdZdZddZeideiƒZ d„Z!dfd„ƒYZ"de"fd„ƒYZ#e$e%ei&dƒƒZ'de'Z(e)d„Z*dS(s;Classes to generate plain text from a message object tree. N(sListTypes StringType(sStringIO(sHeader(sNLCRE(s _isstringiiss; s|s_s s s; s is^From cCsGt|tƒo/yt|dƒWq?tj o tSq?XntSdS(Nsus-ascii(s isinstancesss StringTypesunicodes UnicodeErrorsTruesFalse(ss((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys _is8bitstring)s  s GeneratorcBs†tZdZedd„Zd„Zed„ZeZd„Z d„Z d„Z d„Z d „Z e 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 be broken on semicolons and continued as per RFC 2822. If no semicolon is found, then the header is left alone. Set to zero to disable wrapping headers. Default is 78, as recommended (but not required by RFC 2822. N(soutfpsselfs_fps mangle_from_s _mangle_from_s maxheaderlens_Generator__maxheaderlen(sselfsoutfps mangle_from_s maxheaderlen((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys__init__=s  cCs|ii|ƒdS(N(sselfs_fpswritess(sselfss((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pyswriteSscCsZ|oB|iƒ}| odtitiƒƒ}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( sunixfromsmsgs get_unixfromsufromstimesctimesselfs_fps_write(sselfsmsgsunixfromsufrom((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pysflattenWs  cCs|i||i|iƒSdS(s1Clone this generator with the exact same options.N(sselfs __class__sfps _mangle_from_s_Generator__maxheaderlen(sselfsfp((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pysclonelscCs‹|i}z!tƒ|_}|i|ƒWd||_Xt|dtƒ}|tjo|i |ƒn ||ƒ|ii |i ƒƒdS(Ns_write_headers( sselfs_fpsoldfpsStringIOssfps _dispatchsmsgsgetattrsNonesmeths_write_headersswritesgetvalue(sselfsmsgsoldfpssfpsmeth((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys_writets    cCs°|iƒ}|iƒ}ti||fƒiddƒ}t |d|t ƒ}|t joF|iddƒ}t |d|t ƒ}|t jo |i}q¢n||ƒdS(Ns-s_s_handle_(smsgsget_content_maintypesmainsget_content_subtypessubs UNDERSCOREsjoinsreplacesspecificsgetattrsselfsNonesmethsgenerics _writeBody(sselfsmsgssubsgenericsspecificsmethsmain((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys _dispatchs  !  cCsÍ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:is maxlinelens header_namescontinuation_wss ( smsgsitemsshsvsselfs_fps_Generator__maxheaderlens isinstancesHeadersencodes _is8bitstring(sselfsmsgshsv((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys_write_headers£s  cCs¦|iƒ}|tjodSn|iƒ}|tj o|i|ƒ}nt|ƒ otdt |ƒ‚n|i ot i d|ƒ}n|ii|ƒdS(Nsstring payload expected: %ss>From (smsgs get_payloadspayloadsNones get_charsetscsets body_encodes _isstrings TypeErrorstypesselfs _mangle_from_sfcressubs_fpswrite(sselfsmsgscsetspayload((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys _handle_textÀs     c CsQg}|iƒ}|tjoP|idtƒƒ} |i d| IJ|i dIJ|i d| dIJdSnDt |ƒo|i i |ƒdSnt |t ƒ o |g}nxL|D]D}tƒ}|i|ƒ}|i|dtƒ|i|iƒƒq¹Wti|ƒ}|idt|ƒƒ} |iƒ| jo|i| ƒn|itj o^|i i |iƒti|iƒ} | dgjo| ddjo|i i dƒqºn|i d| IJd| d}|i i |i|ƒƒ|i d| dI|i tj o6|i i!dƒ o |i Jn|i i |i ƒndS(Nsfailobjs--s sunixfromsiÿÿÿÿs --("smsgtextssmsgs get_payloadssubpartssNones get_boundarys_make_boundarysboundarysselfs_fps _isstringswrites isinstancesListTypespartsStringIOsssclonesgsflattensFalsesappendsgetvaluesNLsjoinsalltexts set_boundaryspreamblesNLCREssplitsplinessjoinersepilogues startswith( sselfsmsgsalltextsgsmsgtextssjoinerssubpartsssspartsboundarysplines((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys_handle_multipartÐsH      ! cCsÃg}x|iƒD]}tƒ}|i|ƒ}|i |dt ƒ|i ƒ}|i dƒ}|o|ddjo|iti|d ƒƒq|i|ƒqW|iiti|ƒƒdS(Nsunixfroms iÿÿÿÿs(sblockssmsgs get_payloadspartsStringIOsssselfsclonesgsflattensFalsesgetvaluestextssplitslinessappendsNLsjoins_fpswrite(sselfsmsgsblockssgstextslinesssspart((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys_handle_message_delivery_statuss   cCsNtƒ}|i|ƒ}|i|idƒdtƒ|i i |i ƒƒdS(Nisunixfrom( sStringIOsssselfsclonesgsflattensmsgs get_payloadsFalses_fpswritesgetvalue(sselfsmsgsgss((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys_handle_message#s (s__name__s __module__s__doc__sTrues__init__swritesFalsesflattens__call__sclones_writes _dispatchs_write_headerss _handle_texts _writeBodys_handle_multiparts_handle_message_delivery_statuss_handle_message(((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys Generator3s         > sDecodedGeneratorcBs)tZdZeded„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||||ƒ|tjo d}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] sD[Non-text (%(type)s) part of message omitted, filename %(filename)s]N( s Generators__init__sselfsoutfps mangle_from_s maxheaderlensfmtsNones_fmt(sselfsoutfps mangle_from_s maxheaderlensfmt((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys__init__5s   c CsåxÞ|iƒD]Ð}|idƒ}|djo||idtƒIJq |djoq ||ihd|i dƒ<d|idƒ<d|i d ƒ<d |i d ƒ<d |i d dƒ<d|i ddƒ<IJq WdS(Nstextsdecodes multipartstypes[no MIME type]smaintypes[no main MIME type]ssubtypes[no sub-MIME type]sfilenames [no filename]s descriptionsContent-Descriptions[no description]sencodingsContent-Transfer-Encodings [no encoding]( smsgswalksparts get_main_typesmaintypesselfs get_payloadsTrues_fmtsget_types get_subtypes get_filenamesget(sselfsmsgspartsmaintype((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys _dispatchQs   b(s__name__s __module__s__doc__sTruesNones__init__s _dispatch(((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pysDecodedGenerator/s s%%0%ddcCsºtitiƒ}ddt|d}|tjo|Sn|}d}xft o^t i dt i|ƒdt iƒ}|i|ƒ oPn|dt|ƒ}|d7}qLW|SdS( Ns=is==is^--s(--)?$s.i(srandoms randrangessyssmaxintstokens_fmtsboundarystextsNonesbscountersTruesrescompilesescapes MULTILINEscressearchsstr(stextsbstokenscresboundaryscounter((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys_make_boundaryks &(+s__doc__sressysstimeslocalesrandomstypessListTypes StringTypes cStringIOsStringIOs email.HeadersHeaders email.ParsersNLCREsemail._compat22s _isstrings SyntaxErrorsemail._compat21sTruesFalses NameErrors EMPTYSTRINGs SEMISPACEsBARs UNDERSCOREsNLsNLTABs SEMINLTABsSPACE8scompiles MULTILINEsfcres _is8bitstrings GeneratorsDecodedGeneratorslensreprsmaxints_widths_fmtsNones_make_boundary(sNLCREsBARs Generatorslocales _isstringsrandoms_make_boundarys UNDERSCOREsNLTABs StringTypesNLsresTrues_fmts SEMINLTABssyssListTypes SEMISPACEsfcresFalsesDecodedGeneratorsStringIOs_widths _is8bitstrings EMPTYSTRINGsHeaderstimesSPACE8((s1/usr/pkg/lib/mailman/pythonlib/email/Generator.pys?sB           ü9