bgD >ddlmZddlmZddlmZddlmZddlmZgdZddlm Z ddl m Z dd l m Z dd lmZd Zd Zd ZdZdZdZdZideedfdeedfdeedfdeedfdeedfdeedfdeedfdeedfdeedfdeedfdeedfdeedfddd eedfd!eedfd"edd#fd$edd#feddfeedfeed%fd&Zid'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4dd5dd6dd7ddddd8d"d9dd:Zd;dZd?Zd@ZdAZGdBdCeZdS)D)unicode_literals)division)absolute_import)str)next)Charset add_alias add_charset add_codec)partial)email)errors)encode_7or8bitus-asciiz unknown-8bitz iso-8859-1Nz 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-1252viscii)NNNbig5gb2312zeuc-jp iso-2022-jp shift_jisutf-8)rzkoi8-rrlatin_1zlatin-1latin_2zlatin-2latin_3zlatin-3latin_4zlatin-4latin_5zlatin-5latin_6zlatin-6latin_7zlatin-7latin_8zlatin-8latin_9zks_c_5601-1987zeuc-kr)zlatin-9latin_10zlatin-10cp949euc_jpeuc_krascii eucgb2312_cnbig5_tw)rrrcT|tkrtd|||ft|<dS)a>Add character set properties to the global registry. charset is the input character set, and must be the canonical name of a character set. Optional header_enc and body_enc is either Charset.QP for quoted-printable, Charset.BASE64 for base64 encoding, Charset.SHORTEST for the shortest of qp or base64 encoding, or None for no encoding. SHORTEST is only valid for header_enc. It describes how message headers and message bodies in the input charset are to be encoded. Default is no encoding. Optional output_charset is the character set that the output should be in. Conversions will proceed from input charset, to Unicode, to the output charset when the method Charset.convert() is called. The default is to output in the same character set as the input. Both input_charset and output_charset must have Unicode codec entries in the module's charset-to-codec mapping; use add_codec(charset, codecname) to add codecs the module does not know about. See the codecs module's documentation for more information. z!SHORTEST not allowed for body_encN)SHORTEST ValueErrorCHARSETS)charset header_encbody_encoutput_charsets o/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/future/backports/email/charset.pyr r ns5.8<===#X~>HWc|t|<dS)zAdd a character set alias. alias is the alias name, e.g. latin-1 canonical is the character set's canonical name, e.g. iso-8859-1 N)ALIASES)alias canonicals r4r r s GENNNr5c|t|<dS)a$Add a codec that map characters in the given charset to/from Unicode. charset is the canonical name of a character set. codecname is the name of a Python codec, as appropriate for the second argument to the unicode() built-in, or to the encode() method of a Unicode string. N) CODEC_MAP)r0 codecnames r4r r s#Igr5ct|}|tkr|ddS||S)Nr)surrogateescape)r UNKNOWN8BITencode)stringcodecs r4_encoderCs? [[F }}W&7888}}U###r5cVeZdZdZefdZdZeZdZdZ dZ dZ dZ d Z d Zd Zd S) ra@ Map character sets to their email properties. This class provides information about the requirements imposed on email for a specific character set. It also provides convenience routines for converting between character sets, given the availability of the applicable codecs. Given a character set, it will do its best to provide information on how to use that character set in an email in an RFC-compliant way. Certain character sets must be encoded with quoted-printable or base64 when used in email headers or bodies. Certain character sets must be converted outright, and are not allowed in email. Instances of this module expose the following information about a character set: input_charset: The initial character set specified. Common aliases are converted to their `official' email names (e.g. latin_1 is converted to iso-8859-1). Defaults to 7-bit us-ascii. header_encoding: If the character set must be encoded before it can be used in an email header, this attribute will be set to Charset.QP (for quoted-printable), Charset.BASE64 (for base64 encoding), or Charset.SHORTEST for the shortest of QP or BASE64 encoding. Otherwise, it will be None. body_encoding: Same as header_encoding, but describes the encoding for the mail message's body, which indeed may be different than the header encoding. Charset.SHORTEST is not allowed for body_encoding. output_charset: Some character sets must be converted before they can be used in email headers or bodies. If the input_charset is one of them, this attribute will contain the name of the charset output will be converted to. Otherwise, it will be None. input_codec: The name of the Python codec used to convert the input_charset to Unicode. If no conversion codec is necessary, this attribute will be None. output_codec: The name of the Python codec used to convert Unicode to the output_charset. If no conversion codec is necessary, this attribute will have the same value as the input_codec. c t|tr|dnt|d}n"#t$rt j|wxYw|}t|||_ t|j ttdf\}}}|s|j }||_ ||_t|||_t |j |j |_t |j|j|_dS)Nr)) isinstancerr@ UnicodeErrorr CharsetErrorlowerr7get input_charsetr/r-BASE64header_encoding body_encodingr3r; input_codec output_codec)selfrKhencbencconvs r4__init__zCharset.__init__s@  5--- <$$W---- #M7 ; ;  5 5 5%m44 4 5%++-- $[[ FF$<<(:)164(@BBdD &%D#!%kk$55%==);)-);==%MM$*=*.*=??s ;>Ac4|jSN)rKrIrQs r4__str__zCharset.__str__s!'')))r5cft|t|kSrW)rrIrQothers r4__eq__zCharset.__eq__s%4yyCJJ,,....r5c.|| SrW)r]r[s r4__ne__zCharset.__ne__s;;u%%%%r5c||jtksJ|jtkrdS|jtkrdStS)aPReturn the content-transfer-encoding used for body encoding. This is either the string `quoted-printable' or `base64' depending on the encoding used, or it is a function in which case you should call the function with a single argument, the Message object being encoded. The function should then set the Content-Transfer-Encoding header itself to whatever is appropriate. Returns "quoted-printable" if self.body_encoding is QP. Returns "base64" if self.body_encoding is BASE64. Returns conversion function otherwise. zquoted-printablebase64)rNr-QPrLrrXs r4get_body_encodingzCharset.get_body_encodingsE!X----   # #%%  6 ) )8! !r5c|jp|jS)zReturn the output character set. This is self.output_charset if that is not None, otherwise it is self.input_charset. )r3rKrXs r4get_output_charsetzCharset.get_output_charsets "8d&88r5c|jpd}t||}||}||S|||S)aHeader-encode a string by converting it first to bytes. The type of encoding (base64 or quoted-printable) will be based on this charset's `header_encoding`. :param string: A unicode string for the header. It must be possible to encode this string to bytes using the character set's output codec. :return: The encoded string, with RFC 2047 chrome. r)rPrC _get_encoder header_encode)rQrArB header_bytesencoder_modules r4rhzCharset.header_encodesT!/Zvu-- **<88  !M++L%@@@r5c||jpd}t||}||}t|j|}|}t |tz}g} g} t||z } |D]} | | t | } | t| |}|| kr| | s| s| dnN| rdnd}t | }t||}| ||| g} t||z } t | }t||}| ||| S)afHeader-encode a string by converting it first to bytes. This is similar to `header_encode()` except that the string is fit into maximum line lengths as given by the argument. :param string: A unicode string for the header. It must be possible to encode this string to bytes using the character set's output codec. :param maxlengths: Maximum line length iterator. Each element returned from this iterator will provide the next maximum line length. This parameter is used as an argument to built-in next() and should never be exhausted. The maximum line lengths should not count the RFC 2047 chrome. These line lengths are only a hint; the splitter does the best it can. :return: Lines of encoded strings, each with RFC 2047 chrome. r)r0N r)rPrCrgr rhrelenRFC2047_CHROME_LENrappend EMPTYSTRINGjoin header_lengthpop)rQrA maxlengthsrBrirjencoderr0extralines current_linemaxlen character this_linelength separator joined_lines r4header_encode_lineszCharset.header_encode_lines/s$!/Zvu-- **<88.6FFF))++G 11 j!!E) 2 2I    * * *#((66I#11')W2M2MNNF  """8\8LL&&&&(-!52I"-"2"2<"@"@K#*;#>#>LLL!6!6777 ){ j))E1!&&|44 {E22  WW\**+++ r5cN|jtkr tjS|jtkr tjS|jt kr\tj|}tj|}||kr tjStjSdSrW)rMrLr base64mimerb quoprimimer-rr)rQrilen64lenqps r4rgzCharset._get_encoderms  6 ) )# #  !R ' '# #  !X - -$22<@@E$22<@@Eu}}''''4r5c,|s|S|jturNt|tr||j}t j|S|jturct|tr||j}| d}t j |St|tr-||j d}|S)avBody-encode a string by converting it first to bytes. The type of encoding (base64 or quoted-printable) will be based on self.body_encoding. If body_encoding is None, we assume the output charset is a 7bit encoding, so re-encoding the decoded string using the ascii codec produces the correct string version of the content. latin1r)) rNrLrFrr@r3r r body_encoderbdecoder)rQrAs r4rzCharset.body_encode|s M   ' '&#&& <t':;;#//77 7  2 % %&#&& <t':;;]]8,,F#//77 7&#&& Lt':;;BB7KKMr5N)__name__ __module__ __qualname____doc__DEFAULT_CHARSETrUrY__repr__r]r_rcrerhrrgrr5r4rrs**V&5????B***H///&&&"""*999AAA&<<<|   r5r) __future__rrrfuture.builtinsrr__all__ functoolsr future.backportsr future.backports.emailrfuture.backports.email.encodersrrbrLr-rnrr?rpr/r7r;r r r rCobjectrrr5r4rs''''''&&&&&&    """"""))))))::::::   Br- Br- Br-   Br-  Br- Br- Br- Br- Br-  Br-! "Br-# $ Br-% &-' ( Fv-) * Fv-+ , Ft 6- .Ft 6/ 0t-v-vw/5   >  |  | | |   |   |  | | | | } } } } }  }! "}# $1   <"    ????8###$$$rrrrrfrrrrrr5