ž ¦ÿféc@svdZddlZddlZddlZddlZddlmZmZddlm Z ddddd d d d gZ ej ej d ƒj dd„ƒZdd„ZGdd„deƒZeƒZdeedƒAsucCs"|jddƒ}t|ƒgfS(Ns_s (ureplaceu_q_byte_subber(uencoded((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyudecode_qCscBs@|EeZdZdejdƒejdƒZdd„ZdS(u _QByteMaps-!*+/uasciicCs=||jkr"t|ƒ||Zsuencode_q..(ujoin(ubstring((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyuencode_qYscCstdd„|DƒƒS(Ncss|]}tt|ƒVqdS(N(ulenu _q_byte_map(u.0ux((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyu ]sulen_q..(usum(ubstring((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyulen_q\scCsg}t|ƒd}|rJ|jtjƒƒ|ddd|…}n|}ytj|dd ƒ|fSWn tjk rtj ƒg}xyd D]e}y%tj|d|dd ƒ|fSWq–tjk rú|dkrö|jtjƒƒnYq–Xq–Wt d ƒ‚YnXdS( Nis===uvalidateiiiis=uunexpected binascii.ErrorT(iiiiF( ulenuappenduerrorsuInvalidBase64PaddingDefectubase64u b64decodeuTrueubinasciiuErroruInvalidBase64CharactersDefectuFalseuAssertionError(uencodedudefectsupad_errupadded_encodedui((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyudecode_bds" % cCstj|ƒjdƒS(Nuascii(ubase64u b64encodeudecode(ubstring((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyuencode_b~scCs3tt|ƒdƒ\}}|d|r.dndS(Niii(udivmodulen(ubstringu groups_of_3uleftover((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyulen_bsuqubc Cs*|jdƒ\}}}}}|jdƒ\}}}|jƒ}|jddƒ}t||ƒ\}}y|j|ƒ}Wnštk rÂ|jtj dj |ƒƒƒ|j|dƒ}YnXt k r|jddƒ}|jƒdkr|jtj dj |ƒƒƒnYnX||||fS(uŒDecode encoded word and return (string, charset, lang, defects) tuple. An RFC 2047/2243 encoded word has the form: =?charset*lang?cte?encoded_string?= where '*lang' may be omitted but the other parts may not be. This function expects exactly such a string (that is, it does not check the syntax and may raise errors if the string is not well formed), and returns the encoded_string decoded first from its Content Transfer Encoding and then from the resulting bytes into unicode using the specified charset. If the cte-decoded string does not successfully decode using the specified character set, a defect is added to the defects list and the unknown octets are replaced by the unicode 'unknown' character ï·¿. The specified charset and language are returned. The default for language, which is rarely if ever encountered, is the empty string. u?u*uasciiusurrogateescapeu:Encoded word contains bytes not decodable using {} charsetu unknown-8bitu<Unknown charset {} in encoded word; decoded as unknown bytes( usplitu partitionuloweruencodeu _cte_decodersudecodeu UnicodeErroruappenduerrorsuUndecodableBytesDefectuformatu LookupErroru CharsetError( uewu_ucharsetucteu cte_stringulangubstringudefectsustring((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyudecodeŒs"    uutf-8ucCs´|dkr!|jddƒ}n|j|ƒ}|d kr{td|ƒ}td|ƒ}||dkrrdnd}nt||ƒ}|ržd|}ndj||||ƒS( uEncode string using the CTE encoding that produces the shorter result. Produces an RFC 2047/2243 encoded word of the form: =?charset*lang?cte?encoded_string?= where '*lang' is omitted unless the 'lang' parameter is given a value. Optional argument charset (defaults to utf-8) specifies the charset to use to encode the string to binary before CTE encoding it. Optional argument 'encoding' is the cte specifier for the encoding that should be used ('q' or 'b'); if it is None (the default) the encoding which produces the shortest encoded sequence is used, except that 'q' is preferred if it is up to five characters longer. Optional argument 'lang' (default '') gives the RFC 2243 language string to specify in the encoded word. u unknown-8bituasciiusurrogateescapeuqubiu*u=?{}{}?{}?{}?=N(uencodeuNoneu_cte_encode_lengthu _cte_encodersuformat(ustringucharsetuencodingulangubstringuqlenublenuencoded((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyuencodeÀs   (u__doc__ureubase64ubinasciiu functoolsustringu ascii_lettersudigitsuemailuerrorsu__all__upartialucompileusubu_q_byte_subberudecode_qudictu _QByteMapu _q_byte_mapuorduencode_qulen_qudecode_buencode_bulen_bu _cte_decodersudecodeu _cte_encodersu_cte_encode_lengthuNoneuencode(((u9/opt/alt/python33/lib64/python3.3/email/_encoded_words.pyusH$              *