U e5dèBã@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ééééúus-asciiz unknown-8bitÚ)NNNú iso-2022-jpúutf-8)ú iso-8859-1ú iso-8859-2ú iso-8859-3ú iso-8859-4ú iso-8859-9ú iso-8859-10ú iso-8859-13ú iso-8859-14ú iso-8859-15ú iso-8859-16z windows-1252Zvisciir Úbig5Úgb2312úeuc-jpÚ shift_jisrzkoi8-rrrrrrrrrrrrzks_c_5601-1987rzeuc-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)rrr cCs"|tkrtdƒ‚|||ft|<dS)Nz!SHORTEST not allowed for body_enc)ÚSHORTESTÚ ValueErrorÚCHARSETS)ÚcharsetZ header_encZbody_encÚoutput_charset©r+ú%/usr/lib64/python3.8/email/charset.pyrmscCs |t|<dS©N)ÚALIASES)ÚaliasZ canonicalr+r+r,r‰scCs |t|<dSr-)Ú CODEC_MAP)r)Z codecnamer+r+r,r’scCs"|tkr| dd¡S| |¡SdS)Nr#Úsurrogateescape)Ú UNKNOWN8BITÚencode)ÚstringÚcodecr+r+r,Ú_encodeŸs r6c@sXeZdZefdd„Zdd„Zdd„Zdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z dS)rcCsÀz$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Ústrr3Ú UnicodeErrorrZ CharsetErrorÚlowerr.ÚgetÚ input_charsetr(r&ÚBASE64Úheader_encodingÚ body_encodingr*r0Z input_codecÚ output_codec)Úselfr<ZhencZbencZconvr+r+r,Ú__init__Ós,  ÿ ÿÿzCharset.__init__cCs |j ¡Sr-)r<r:©rAr+r+r,Ú__repr__ôszCharset.__repr__cCst|ƒt|ƒ ¡kSr-)r8r:)rAÚotherr+r+r,Ú__eq__÷szCharset.__eq__cCs$|jtkrdS|jtkrdStSdS)Nzquoted-printableÚbase64)r?ÚQPr=rrCr+r+r,Úget_body_encodingús   zCharset.get_body_encodingcCs |jp |jSr-)r*r<rCr+r+r,Úget_output_charsetszCharset.get_output_charsetcCs6|jpd}t||ƒ}| |¡}|dkr*|S| ||¡S)Nr )r@r6Ú _get_encoderÚ header_encode)rAr4r5Ú header_bytesÚencoder_moduler+r+r,rLs   zCharset.header_encodecCs |jpd}t||ƒ}| |¡}t|j|d}| ¡}t|ƒt}g} g} t|ƒ|} |D]Œ} |   | ¡t   | ¡} |  t| |ƒ¡}|| krX|   ¡| s¤| s¤|   d¡n.| r¬dnd}t   | ¡}t||ƒ}|   ||ƒ¡| g} t|ƒ|} qXt   | ¡}t||ƒ}|   ||ƒ¡| S)Nr )r)ú r)r@r6rKrrLrJÚlenÚRFC2047_CHROME_LENÚnextÚappendÚ EMPTYSTRINGÚjoinÚ header_lengthÚpop)rAr4Z maxlengthsr5rMrNÚencoderr)ZextraÚlinesZ current_lineÚmaxlenÚ characterZ this_lineZlengthZ separatorZ joined_liner+r+r,Úheader_encode_lines*s6             zCharset.header_encode_linescCs`|jtkrtjS|jtkr tjS|jtkrXtj |¡}tj |¡}||krPtjStjSndSdSr-)r>r=ÚemailÚ base64mimerHÚ quoprimimer&rV)rArMZlen64Zlenqpr+r+r,rKhs     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#) r?r=r7r8r3r*r]r^Ú body_encoderHÚdecoder_)rAr4r+r+r,raws           zCharset.body_encodeN) Ú__name__Ú __module__Ú __qualname__ÚDEFAULT_CHARSETrBrDrFrIrJrLr\rKrar+r+r+r,r§s, !>)NNN)Ú__all__Ú functoolsrZemail.base64mimer]Zemail.quoprimimerZemail.encodersrrHr=r&rQrfr2rTr(r.r0rrrr6rr+r+r+r,ÚsŽü   æ èú