AlkantarClanX12

Your IP : 3.149.239.79


Current Path : /lib64/python3.8/email/__pycache__/
Upload File :
Current File : //lib64/python3.8/email/__pycache__/charset.cpython-38.opt-1.pyc

U

e5d�B�@srddddgZddlmZddlZddlZddlmZddlmZd	Z	d
Z
dZd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
dfee
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)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�
ValueError�CHARSETS)�charsetZ
header_encZbody_enc�output_charset�r+�%/usr/lib64/python3.8/email/charset.pyrmscCs|t|<dS)z�Add 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)�aliasZ	canonicalr+r+r,r�scCs|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)r)Z	codecnamer+r+r,r�scCs"|tkr|�dd�S|�|�SdS)Nr#�surrogateescape)�UNKNOWN8BIT�encode)�string�codecr+r+r,�_encode�sr5c@s\eZdZdZefdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dS)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.
    cCs�z$t|t�r|�d�n
t|d�}Wntk
rBt�|��YnX|��}t�||�|_	t
�|j	ttdf�\}}}|s~|j	}||_
||_t�||�|_t�|j	|j	�|_t�|j|j�|_dS)Nr#)�
isinstance�strr2�UnicodeErrorrZCharsetError�lowerr-�get�
input_charsetr(r&�BASE64�header_encoding�
body_encodingr*r/Zinput_codec�output_codec)�selfr;ZhencZbencZconvr+r+r,�__init__�s,
�
��zCharset.__init__cCs
|j��S�N)r;r9�r@r+r+r,�__repr__�szCharset.__repr__cCst|�t|���kSrB)r7r9)r@�otherr+r+r,�__eq__�szCharset.__eq__cCs$|jtkrdS|jtkrdStSdS)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-printable�base64N)r>�QPr<rrCr+r+r,�get_body_encoding�s


zCharset.get_body_encodingcCs|jp
|jS)z�Return the output character set.

        This is self.output_charset if that is not None, otherwise it is
        self.input_charset.
        )r*r;rCr+r+r,�get_output_charsetszCharset.get_output_charsetcCs6|jpd}t||�}|�|�}|dkr*|S|�||�S)a�Header-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
N)r?r5�_get_encoder�
header_encode)r@r3r4�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)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
)r)N� r)r?r5rKrrLrJ�len�RFC2047_CHROME_LEN�next�append�EMPTYSTRING�join�
header_length�pop)r@r3Z
maxlengthsr4rMrN�encoderr)Zextra�linesZcurrent_line�maxlen�	characterZ	this_lineZlengthZ	separatorZjoined_liner+r+r,�header_encode_lines*s6








zCharset.header_encode_linescCs`|jtkrtjS|jtkr tjS|jtkrXtj�|�}tj�|�}||krPtjStjSndSdSrB)r=r<�email�
base64mimerH�
quoprimimer&rV)r@rMZlen64Zlenqpr+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)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#N)r>r<r6r7r2r*r]r^�body_encoderH�decoder_)r@r3r+r+r,raws	





zCharset.body_encodeN)�__name__�
__module__�__qualname__�__doc__�DEFAULT_CHARSETrArDrFrIrJrLr\rKrar+r+r+r,r�s+!>)NNN)�__all__�	functoolsrZemail.base64mimer]Zemail.quoprimimerZemail.encodersrrHr<r&rQrgr1rTr(r-r/rrrr5rr+r+r+r,�<module>s��� ��