B ¼¬z²Žüã@srddddgZddlmZddlZddlZddlmZddlmZd Z d Z d Z d Z d Z dZdZe e dfe e dfe e dfe e dfe e dfe e dfe e dfe e dfe e dfe e dfe e dfe e dfde e dfe e dfe ddfe ddfe ddfe e dfe e dfdœZddddddddddddddddddddddd d d!œZd"d#dd$œZd+d%d„Zd&d„Zd'd„Zd(d)„ZGd*d„dƒZdS),ÚCharsetÚ add_aliasÚ add_charsetÚ add_codecé)ÚpartialN)Úerrors)Úencode_7or8bitéééézus-asciiz unknown-8bitÚ)NNNz iso-2022-jpzutf-8)z iso-8859-1z iso-8859-2z iso-8859-3z iso-8859-4z iso-8859-9z iso-8859-10z iso-8859-13z iso-8859-14z iso-8859-15z iso-8859-16z windows-1252Zvisciizus-asciiÚbig5Úgb2312zeuc-jpÚ shift_jisz iso-2022-jpzkoi8-rzutf-8z iso-8859-1z iso-8859-2z iso-8859-3z iso-8859-4z iso-8859-9z iso-8859-10z iso-8859-13z iso-8859-14z iso-8859-15z iso-8859-16zks_c_5601-1987zeuc-jpzeuc-kr)Úlatin_1zlatin-1Zlatin_2zlatin-2Zlatin_3zlatin-3Zlatin_4zlatin-4Zlatin_5zlatin-5Zlatin_6zlatin-6Zlatin_7zlatin-7Zlatin_8zlatin-8Zlatin_9zlatin-9Zlatin_10zlatin-10Úcp949Úeuc_jpÚeuc_krÚasciiÚ eucgb2312_cnÚbig5_tw)rrzus-asciicCs"|tkrtdƒ‚|||ft|<dS)Nz!SHORTEST not allowed for body_enc)ÚSHORTESTÚ ValueErrorÚCHARSETS)ÚcharsetZ header_encZbody_encÚoutput_charset©rú0/opt/alt/python37/lib/python3.7/email/charset.pyrmscCs |t|<dS)N)ÚALIASES)ÚaliasZ canonicalrrrr‰scCs |t|<dS)N)Ú CODEC_MAP)rZ codecnamerrrr’scCs"|tkr| dd¡S| |¡SdS)NrÚsurrogateescape)Ú UNKNOWN8BITÚencode)ÚstringÚcodecrrrÚ_encodeŸs r'c@s\eZdZefdd„Zdd„ZeZdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dS)rcCsÀy$t|tƒr| d¡n t|dƒ}Wntk rBt |¡‚YnX| ¡}t ||¡|_ t  |j t t df¡\}}}|s~|j }||_ ||_t ||¡|_t |j |j ¡|_t |j|j¡|_dS)Nr)Ú isinstanceÚstrr$Ú UnicodeErrorrZ CharsetErrorÚlowerrÚgetÚ input_charsetrrÚBASE64Úheader_encodingÚ body_encodingrr!Z input_codecÚ output_codec)Úselfr-ZhencZbencÚconvrrrÚ__init__Ós&   zCharset.__init__cCs |j ¡S)N)r-r+)r2rrrÚ__str__ôszCharset.__str__cCst|ƒt|ƒ ¡kS)N)r)r+)r2ÚotherrrrÚ__eq__ùszCharset.__eq__cCs$|jtkrdS|jtkrdStSdS)Nzquoted-printableÚbase64)r0ÚQPr.r)r2rrrÚget_body_encodingüs   zCharset.get_body_encodingcCs |jp |jS)N)rr-)r2rrrÚget_output_charsetszCharset.get_output_charsetcCs6|jpd}t||ƒ}| |¡}|dkr*|S| ||¡S)Nzus-ascii)r1r'Ú _get_encoderÚ header_encode)r2r%r&Ú header_bytesÚencoder_modulerrrr=s   zCharset.header_encodecCs|jpd}t||ƒ}| |¡}t|j|d}| ¡}t|ƒt}g} g} t|ƒ|} x”|D]Œ} |   | ¡t   | ¡} |  t| |ƒ¡}|| krZ|   ¡| s¦| s¦|   d¡n.| r®dnd}t   | ¡}t||ƒ}|   ||ƒ¡| g} t|ƒ|} qZWt   | ¡}t||ƒ}|   ||ƒ¡| S)Nzus-ascii)rú r )r1r'r<rr=r;ÚlenÚRFC2047_CHROME_LENÚnextÚappendÚ EMPTYSTRINGÚjoinÚ header_lengthÚpop)r2r%Z maxlengthsr&r>r?ÚencoderrZextraÚlinesZ current_lineÚmaxlenÚ characterZ this_lineÚlengthZ separatorZ joined_linerrrÚheader_encode_lines,s6              zCharset.header_encode_linescCs`|jtkrtjS|jtkr tjS|jtkrXtj |¡}tj |¡}||krPtjStjSndSdS)N)r/r.ÚemailÚ base64mimer9Ú quoprimimerrG)r2r>Zlen64Zlenqprrrr<js     zCharset._get_encodercCsŽ|s|S|jtkr4t|tƒr(| |j¡}tj |¡S|jt krjt|tƒrT| |j¡}|  d¡}tj  |¡St|tƒr†| |j¡  d¡}|SdS)NÚlatin1r) r0r.r(r)r$rrOrPÚ body_encoder9ÚdecoderQ)r2r%rrrrSys           zCharset.body_encodeN)Ú__name__Ú __module__Ú __qualname__ÚDEFAULT_CHARSETr4r5Ú__repr__r7r:r;r=rNr<rSrrrrr§s, !>)NNN)Ú__all__Ú functoolsrZemail.base64mimerOZemail.quoprimimerZemail.encodersrr9r.rrBrXr#rErrr!rrrr'rrrrrÚs†