mò &U²Ic@südZdkZdklZdklZdZdZdZei dƒZ ei dƒZ d „Z d „Z d „Zd „Zd d„Zd„Zd„Zdeded„Zeded„ZeZeZed„ZeZeZd„Zd„ZdS(sFQuoted-printable content transfer encoding per RFCs 2045-2047. This module handles the content transfer encoding method defined in RFC 2045 to encode US ASCII-like 8-bit data called `quoted-printable'. It is used to safely encode text that is in a character set similar to the 7-bit US ASCII character set, but that includes some 8-bit characters that are normally not allowed in email bodies or headers. Quoted-printable is very space-inefficient for encoding binary files; use the email.base64MIME module for that instead. This module provides an interface to encode and decode both headers and bodies with quoted-printable encoding. RFC 2045 defines a method for including character set information in an `encoded-word' in a header. This method is commonly used for 8-bit real names in To:/From:/Cc: etc. fields, as well as Subject: lines. This module does not do the line wrapping or end-of-line character conversion necessary for proper internationalized headers; it only does dumb encoding and decoding. To deal with the various line wrapping issues, use the email.Header module. N(s hexdigits(sfix_eolss s is[^-a-zA-Z0-9!*+/ ]s [^ !-<>-~\t]cCstti|ƒƒS(sBReturn True if the character should be escaped with header quopri.N(tboolthqretmatchtc(R((t-/data/zmath/lib/python2.4/email/quopriMIME.pytheader_quopri_check-scCstti|ƒƒS(s@Return True if the character should be escaped with body quopri.N(RtbqreRR(R((Rtbody_quopri_check2scCsCd}x6|D].}ti|ƒo|d7}q |d7}q W|S(s?Return the length of str when it is encoded with header quopri.iiiN(tcounttsRRR(R RR((Rtheader_quopri_len7scCsCd}x6|D].}ti|ƒo|d7}q |d7}q W|S(s=Return the length of str when it is encoded with body quopri.iiiN(RtstrRRR(R RR((Rtbody_quopri_lenBstcCsn|p|i|iƒƒnMt|dƒt|ƒ|jo|dc||7||dt jo)|t |||d!ƒ7}|d7}n||7}|d7}||jo||7}qaqaWq"W|i |ƒ o|i |ƒo|d }n|S( s_Decode a quoted-printable string. Lines are separated with eol, which defaults to \n. R iR+iiiiÿÿÿÿN( tencodedtdecodedR0R)trstripR%tiRtnRt hexdigitsRR2(R:R%R;RR=R>R)((Rtdecodeús>         ;   !cCs|idƒ}t|ƒS(sCTurn a match in the form =AB to the ASCII character with value 0xabiN(RtgroupR R(RR ((Rt_unquote_match/scCs%|iddƒ}tidt|ƒS(sDecode a string encoded with RFC 2045 MIME header `Q' encoding. This function does not parse a full MIME header value encoded with quoted-printable (like =?iso-8895-1?q?Hello_World?=) -- please use the high level email.Header class for that functionality. RRs=\w{2}N(R treplacetretsubRB(R ((Rt header_decode6s(t__doc__RDtstringR?t email.UtilsRR3tNLR$tcompileRRRRR R RRRtFalseR*R9t body_encodet encodestringR@t body_decodet decodestringRBRF(RRBRR RRFRRJRR$R@RDROR*R9RPRR?R3RMRNRRR ((Rt?s0       @S 0