%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/email/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/email/__pycache__/message.cpython-312.pyc

�

���f����dZddgZddlZddlZddlZddlmZmZddlm	Z	ddlm
Z
ddlmZdd	lm
Zdd
lmZej"ZdZej&d�Zd
�Zdd�Zd�Zd�Zd�ZGd�d�ZGd�de�ZGd�de�Zy)z8Basic message object for the email package object model.�Message�EmailMessage�N)�BytesIO�StringIO)�utils)�errors)�compat32��charset)�decode_bz; z[ \(\)<>@,;:\\"/\[\]\?=]c��t|�jd�\}}}|s|j�dfS|j�|j�fS)N�;)�str�	partition�strip)�param�a�sep�bs    �$/usr/lib/python3.12/email/message.py�_splitparamrsH��
�E�
�$�$�S�)�I�A�s�A���w�w�y�$����7�7�9�a�g�g�i���c��|��t|�dkDr�t|t�r,|dz
}tj|d|d|d�}|�d|��S	|jd�|stj|�r|�d	tj|��d
�S|�d|��S|S#t$r&|dz
}tj|dd�}|�d|��cYSwxYw)a~Convenience function to format and return a key=value pair.

    This will quote the value if needed or if quote is true.  If value is a
    three tuple (charset, language, value), it will be encoded according
    to RFC2231 rules.  If it contains non-ascii characters it will likewise
    be encoded according to RFC2231 rules, using the utf-8 charset and
    a null language.
    r�*���=�asciizutf-8�z="�")
�len�
isinstance�tupler�encode_rfc2231�encode�UnicodeEncodeError�	tspecials�search�quote)r�valuer)s   r�_formatparamr+'s���
��S��Z�!�^��e�U�#��S�L�E��(�(��q��5��8�U�1�X�F�E�#�U�+�+�
0����W�%��I�$�$�U�+� %�u�{�{�5�'9�:�:�#�U�+�+����&�
0������,�,�U�G�R�@��"'��/�/�
0�s�B�,C	�C	c�r�dt|�z}g}|dddk(�r|dd}|jd�}|dkDro|jdd|�|jdd|�z
dzrE|jd|dz�}|dkDr+|jdd|�|jdd|�z
dzr�E|dkrt|�}|d|}d|vrL|j	d�}|d|j�j
�dz||dzdj�z}|j|j��||d}|dddk(r��|S)Nrrrr z\"rr)r�find�countr!�indexr�lower�append)�s�plist�end�f�is     r�_parseparamr7Is?���c�!�f��A��E�
�B�Q�%�3�,�
�a�b�E���f�f�S�k���A�g�1�7�7�3��3�/�!�'�'�%��C�2H�H�A�M��&�&��c�A�g�&�C��A�g�1�7�7�3��3�/�!�'�'�%��C�2H�H�A�M���7��a�&�C�
�d�s�G���!�8������A��"�1����
�#�#�%��+�a��!���g�m�m�o�=�A�
���Q�W�W�Y��
�c�d�G���B�Q�%�3�,��Lrc��t|t�r!|d|dtj|d�fStj|�S)Nrrr)r"r#r�unquote)r*s r�
_unquotevaluer:]s?��
�%����Q�x��q��5�=�=��q��#:�:�:��}�}�U�#�#rc�R�g}t|j��}|D]G}|jd�s�|jd�j	d�\}}}	t|d��nt
d��|D]L}|st
d��|jd�dk(rn)	tj|�}|j|��Ndj|�S#t$rY��wxYw#tj$r/|d	d
z
dzdzd
zdz}tj|d|�}Y�twxYw)zDecode uuencoded data.sbegin � �)�basez`begin` line not foundzTruncated inputs 	
sendr� �?���Nr)
�iter�
splitlines�
startswith�removeprefixr�int�
ValueErrorr�binascii�a2b_uu�Errorr1�join)	�encoded�
decoded_lines�encoded_lines_iter�line�mode�_�path�decoded_line�nbytess	         r�
_decode_uurWhs<���M��g�0�0�2�3��"�
3���?�?�9�%� �-�-�i�8�B�B�4�H�M�D�!�T�
��D�q�!��
3��1�2�2�"�+����.�/�/�
�Z�Z��
%��
/��	:�#�?�?�4�0�L�
	���\�*�+��8�8�M�"�"��'�
��
���~�~�	:��Q���
�b�(�A�-��1�a�7�F�#�?�?�4���=�9�L�	:�s$�
C�C$�	C!� C!�$?D&�%D&c�T�eZdZdZefd�Zd�Zd2d�Zd�Zd3d�Z	d	�Z
d
�Zd�Zd�Z
d4d
�Zd5d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd5d�Zd�Zd�Zd5d�Zd�Zd�Z d �Z!d!�Z"d"�Z#d#�Z$d$�Z%d%�Z&d6d&�Z'		d6d'�Z(		d7d(�Z)d8d)�Z*d9d*�Z+d5d+�Z,d5d,�Z-d-�Z.d5d.�Z/d5d/�Z0d0�Z1dd1l2m3Z3y):ra�Basic message object.

    A message object is defined as something that has a bunch of RFC 2822
    headers and a payload.  It may optionally have an envelope header
    (a.k.a. Unix-From or From_ header).  If the message is a container (i.e. a
    multipart or a message/rfc822), then the payload is a list of Message
    objects, otherwise it is a string.

    Message objects implement part of the `mapping' interface, which assumes
    there is exactly one occurrence of the header per message.  Some headers
    do in fact appear multiple times (e.g. Received) and for those headers,
    you must use the explicit API to set or get all the headers.  Not all of
    the mapping methods are implemented.
    c��||_g|_d|_d|_d|_dx|_|_g|_d|_y)N�
text/plain)	�policy�_headers�	_unixfrom�_payload�_charset�preamble�epilogue�defects�
_default_type)�selfr[s  r�__init__zMessage.__init__�sB�������
������
���
�(,�,��
��
����)��rc�"�|j�S)z9Return the entire formatted message as a string.
        )�	as_string�rds r�__str__zMessage.__str__�s���~�~��rrNc��ddlm}|�|jn|}t�}||d||��}|j	||��|j�S)a�Return the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  For backward compatibility reasons, if maxheaderlen is
        not specified it defaults to 0, so you must override it explicitly
        if you want a different maxheaderlen.  'policy' is passed to the
        Generator instance used to serialize the message; if it is not
        specified the policy associated with the message instance is used.

        If the message object contains binary data that is not encoded
        according to RFC standards, the non-compliant data will be replaced by
        unicode "unknown character" code points.
        r)�	GeneratorF)�mangle_from_�maxheaderlenr[��unixfrom)�email.generatorrkr[r�flatten�getvalue)rdrormr[rk�fp�gs       rrgzMessage.as_string�sP��	.� &�����F��
�Z���b�#(�#/�#�
%��	
�	�	�$��	�*��{�{�}�rc�"�|j�S)z?Return the entire formatted message as a bytes object.
        )�as_bytesrhs r�	__bytes__zMessage.__bytes__�s���}�}��rc��ddlm}|�|jn|}t�}||d|��}|j	||��|j�S)aJReturn the entire formatted message as a bytes object.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  'policy' is passed to the BytesGenerator instance used to
        serialize the message; if not specified the policy associated with
        the message instance is used.
        r)�BytesGeneratorF)rlr[rn)rpryr[rrqrr)rdror[ryrsrts      rrvzMessage.as_bytes�sG��	3� &�����F��
�Y���2�E�&�A��	�	�	�$��	�*��{�{�}�rc�6�t|jt�S)z6Return True if the message consists of multiple parts.)r"r^�listrhs r�is_multipartzMessage.is_multipart�s���$�-�-��.�.rc��||_y�N�r])rdros  r�set_unixfromzMessage.set_unixfrom�s	��!��rc��|jSr~rrhs r�get_unixfromzMessage.get_unixfrom�s���~�~�rc��|j�	|g|_y	|jj|�y#t$rtd��wxYw)z�Add the given payload to the current payload.

        The current payload will always be a list of objects after this method
        is called.  If you want to set the payload to a scalar object, use
        set_payload() instead.
        Nz=Attach is not valid on a message with a non-multipart payload)r^r1�AttributeError�	TypeError)rd�payloads  r�attachzMessage.attach�sO���=�=� �$�I�D�M�
:��
�
�$�$�W�-��!�
:��!9�:�:�
:�s	�3�Ac�:�|j�r |ry|�|jS|j|S|�;t|jt�s!t	dt|j�z��|j}t
|jdd��j�}|s_t|t�rMtj|�r8	|jdd�}	|j|jdd�d�}|S|St|t�r	|jdd�}|d
k(rt!j"�S|dk(rPt%dj'j)���\}}|D]}|j*j-||�� |S|d
vr	t/�St|t�rS|S#t$r|jdd�}Y|SwxYw#t$rY|SwxYw#t$r|jd	�}Y��wxYw#t0$rcYSwxYw)aZReturn a reference to the payload.

        The payload will either be a list object or a string.  If you mutate
        the list object, you modify the message's payload in place.  Optional
        i returns that index into the payload.

        Optional decode is a flag indicating whether the payload should be
        decoded or not, according to the Content-Transfer-Encoding header
        (default is False).

        When True and the message is not a multipart, the payload will be
        decoded if this header's value is `quoted-printable' or `base64'.  If
        some other encoding is used, or the header is missing, or if the
        payload has bogus data (i.e. bogus base64 or uuencoded data), the
        payload is returned as-is.

        If the message is a multipart and the decode flag is True, then None
        is returned.
        NzExpected list, got %szcontent-transfer-encodingrr�surrogateescaper�replace�raw-unicode-escapezquoted-printable�base64r)z
x-uuencode�uuencode�uuezx-uue)r|r^r"r{r��typer�getr0r�_has_surrogatesr%�decode�	get_param�LookupErrorr&�quopri�decodestringrrMrEr[�
handle_defectrWrI)	rdr6r�r��cte�bpayloadr*rb�defects	         r�get_payloadzMessage.get_payload�s��D�������y��}�}�$��}�}�Q�'�'�
�=��D�M�M�4�!@��3�d�4�=�=�6I�I�J�J��-�-���$�(�(�6��;�<�B�B�D����'�3�'�E�,A�,A�'�,J��&�~�~�g�7H�I�H�F�"*�/�/�$�.�.��G�2T�V_�"`��
�N�7�N��g�s�#�
@�"�>�>�'�3D�E���$�$��&�&�x�0�0�
�H�_�&�c�h�h�x�/B�/B�/D�&E�F�N�E�7�!�
8�����)�)�$��7�
8��L�
�>�
>�
 �!�(�+�+��g�s�#��O����?'�F�"*�/�/�'�9�"E���N�	F��)����N���&�
@�
#�>�>�*>�?��
@��$�
 ���
 �sT�G�"F:�G,�
H�:G�G�G�G�	G)�(G)�,H	�H	�H�Hc��t|d�rA|�||_yt|t�st|�}|j	|j
d�}t|d�r|j
dd�|_n||_|�|j|�yy)z�Set the payload to the given value.

        Optional charset sets the message's default character set.  See
        set_charset() for details.
        r%Nr�r�r)�hasattrr^r"�Charsetr%�output_charsetr��set_charset)rdr�rs   r�set_payloadzMessage.set_payloadKs����7�H�%��� '��
���g�w�/�!�'�*���n�n�W�%;�%;�=N�O�G��7�H�%�#�N�N�7�4E�F�D�M�#�D�M������W�%�rc���|�|jd�d|_yt|t�st|�}||_d|vr|j	dd�d|vr#|j	dd|j���n |j
d|j��||j�k7r |j|j�|_d|vr|j�}	||�yy#t$rw|j}|r>	|jd	d
�}n*#t$r|j|j�}YnwxYw|j|�|_|j	d|�YywxYw)a�Set the charset of the payload to a given character set.

        charset can be a Charset instance, a string naming a character set, or
        None.  If it is a string it will be converted to a Charset instance.
        If charset is None, the charset parameter will be removed from the
        Content-Type field.  Anything else will generate a TypeError.

        The message will be assumed to be of type text/* encoded with
        charset.input_charset.  It will be converted to charset.output_charset
        and encoded properly, if needed, when generating the plain text
        representation of the message.  MIME headers (MIME-Version,
        Content-Type, Content-Transfer-Encoding) will be added as needed.
        Nr�MIME-Version�1.0�Content-TyperZr
zContent-Transfer-Encodingrr�)�	del_paramr_r"r��
add_header�get_output_charset�	set_param�body_encoder^�get_body_encodingr�r%�UnicodeErrorr�)rdrr�r�s    rr�zMessage.set_charset_s`���?��N�N�9�%� �D�M���'�7�+��g�&�G���
���%��O�O�N�E�2���%��O�O�N�L�$+�$>�$>�$@�
�
B�
�N�N�9�g�&@�&@�&B�C��g�0�0�2�2�#�/�/��
�
�>�D�M�&�d�2��+�+�-�C�

B��D�	�3���
B��-�-���I�")�.�.��:K�"L���'�I�")�.�.��1G�1G�"H��I�� '� 3� 3�G� <��
���� ;�S�A�
B�s6�#C-�-E-�D�E-�$D?�<E-�>D?�?+E-�,E-c��|jS)zKReturn the Charset instance associated with the message's payload.
        )r_rhs r�get_charsetzMessage.get_charset�s���}�}�rc�,�t|j�S)z9Return the total number of headers, including duplicates.)r!r\rhs r�__len__zMessage.__len__�s���4�=�=�!�!rc�$�|j|�S)a-Get a header value.

        Return None if the header is missing instead of raising an exception.

        Note that if the header appeared multiple times, exactly which
        occurrence gets returned is undefined.  Use get_all() to get all
        the values matching a header field name.
        )r�)rd�names  r�__getitem__zMessage.__getitem__�s���x�x��~�rc�f�|jj|�}|r_|j�}d}|jD]>\}}|j�|k(s�|dz
}||k\s�%t	dj||���|jj
|jj||��y)z�Set the value of a header.

        Note: this does not overwrite an existing header with the same field
        name.  Use __delitem__() first to delete any existing headers.
        rrz/There may be at most {} {} headers in a messageN)r[�header_max_countr0r\rI�formatr1�header_store_parse)rdr��val�	max_count�lname�found�k�vs        r�__setitem__zMessage.__setitem__�s����K�K�0�0��6�	���J�J�L�E��E��
�
�
Q���1��7�7�9��%��Q�J�E��	�)�(�*8�8>��y�$�8O�Q�Q�	
Q�	
�
�
���T�[�[�;�;�D�#�F�Grc��|j�}g}|jD],\}}|j�|k7s�|j||f��.||_y)zwDelete all occurrences of a header, if present.

        Does not raise an exception if the header is missing.
        N)r0r\r1)rdr��
newheadersr�r�s     r�__delitem__zMessage.__delitem__�sT��
�z�z�|���
��M�M�	*�D�A�q��w�w�y�D� ��!�!�1�a�&�)�	*�#��
rc�v�|j�}|jD]\}}||j�k(s�yy)NTF)r0r\)rdr��
name_lowerr�r�s     r�__contains__zMessage.__contains__�s:���Z�Z�\�
��M�M�	�D�A�q��Q�W�W�Y�&��	�rc#�<K�|jD]	\}}|���y�wr~�r\)rd�fieldr*s   r�__iter__zMessage.__iter__�s"���� �M�M�	�L�E�5��K�	�s�c�L�|jD��cgc]\}}|��	c}}Scc}}w)a.Return a list of all the message's header field names.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        r��rdr�r�s   r�keyszMessage.keys�s ��#�m�m�,�d�a���,�,��,s� c��|jD��cgc]!\}}|jj||���#c}}Scc}}w)a)Return a list of all the message's header values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        �r\r[�header_fetch_parser�s   r�valueszMessage.values�s=��!�M�M�+��A�q����.�.�q�!�4�+�	+��+s�&:c	��|jD��cgc]#\}}||jj||�f��%c}}Scc}}w)a'Get all the message's header fields and values.

        These will be sorted in the order they appeared in the original
        message, or were added to the message, and may contain duplicates.
        Any fields deleted and re-inserted are always appended to the header
        list.
        r�r�s   r�itemsz
Message.items�sB��!�M�M�+��A�q��D�K�K�2�2�1�a�8�9�+�	+��+s�(<c��|j�}|jD]6\}}|j�|k(s�|jj||�cS|S)z~Get a header value.

        Like __getitem__() but return failobj instead of None when the field
        is missing.
        )r0r\r[r�)rdr��failobjr�r�s     rr�zMessage.get�sR���z�z�|���M�M�	<�D�A�q��w�w�y�D� ��{�{�5�5�a��;�;�	<��rc�>�|jj||f�y)z�Store name and value in the model without modification.

        This is an "internal" API, intended only for use by a parser.
        N)r\r1)rdr�r*s   r�set_rawzMessage.set_raw�s��
	
�
�
���d�E�]�+rc�H�t|jj��S)z�Return the (name, value) header pairs without modification.

        This is an "internal" API, intended only for use by a generator.
        )rDr\�copyrhs r�	raw_itemszMessage.raw_itemss��
�D�M�M�&�&�(�)�)rc���g}|j�}|jD]D\}}|j�|k(s�|j|jj	||���F|s|S|S)aQReturn a list of all the values for the named field.

        These will be sorted in the order they appeared in the original
        message, and may contain duplicates.  Any fields deleted and
        re-inserted are always appended to the header list.

        If no such fields exist, failobj is returned (defaults to None).
        )r0r\r1r[r�)rdr�r�r�r�r�s      r�get_allzMessage.get_allsg�����z�z�|���M�M�	D�D�A�q��w�w�y�D� ��
�
�d�k�k�<�<�Q��B�C�	D���N��
rc	�.�g}|j�D]T\}}|�"|j|jdd���*|jt|jdd�|���V|�|j	d|�t
j
|�||<y)u�Extended header setting.

        name is the header field to add.  keyword arguments can be used to set
        additional parameters for the header field, with underscores converted
        to dashes.  Normally the parameter will be added as key="value" unless
        value is None, in which case only the key will be added.  If a
        parameter value contains non-ASCII characters it can be specified as a
        three-tuple of (charset, language, value), in which case it will be
        encoded according to RFC2231 rules.  Otherwise it will be encoded using
        the utf-8 charset and a language of ''.

        Examples:

        msg.add_header('content-disposition', 'attachment', filename='bud.gif')
        msg.add_header('content-disposition', 'attachment',
                       filename=('utf-8', '', Fußballer.ppt'))
        msg.add_header('content-disposition', 'attachment',
                       filename='Fußballer.ppt'))
        NrS�-r)r�r1r�r+�insert�	SEMISPACErM)rd�_name�_value�_params�partsr�r�s       rr�zMessage.add_header#s���(���M�M�O�	C�D�A�q��y����Q�Y�Y�s�C�0�1����\�!�)�)�C��*=�q�A�B�		C�
���L�L��F�#��n�n�U�+��U�rc�.�|j�}ttt|j��|j�D]F\}\}}|j�|k(s�|j
j
||�|j|<yt|��)z�Replace a header.

        Replace the first matching header found in the message, retaining
        header order and case.  If no matching header was found, a KeyError is
        raised.
        N)r0�zip�ranger!r\r[r��KeyError)rdr�r�r6r�r�s      r�replace_headerzMessage.replace_headerAs{�����
���U�3�t�}�}�#5�6��
�
�F�	"�I�A�v��1��w�w�y�E�!�#'�;�;�#A�#A�!�V�#L��
�
�a� ��	"�
�5�/�!rc���t�}|jd|�}||ur|j�St|�dj	�}|jd�dk7ry|S)a0Return the message's content type.

        The returned string is coerced to lower case of the form
        `maintype/subtype'.  If there was no Content-Type header in the
        message, the default type as given by get_default_type() will be
        returned.  Since according to RFC 2045, messages always have a default
        type this will always return a value.

        RFC 2045 defines a message's default type to be text/plain unless it
        appears inside a multipart/digest container, in which case it would be
        message/rfc822.
        �content-typer�/rrZ)�objectr��get_default_typerr0r.)rd�missingr*�ctypes    r�get_content_typezMessage.get_content_typeTsc���(�������1���G���(�(�*�*��E�"�1�%�+�+�-���;�;�s��q� ���rc�J�|j�}|jd�dS)z�Return the message's main content type.

        This is the `maintype' part of the string returned by
        get_content_type().
        r�r�r��split�rdr�s  r�get_content_maintypezMessage.get_content_maintypel�&���%�%�'���{�{�3���"�"rc�J�|j�}|jd�dS)z�Returns the message's sub-content type.

        This is the `subtype' part of the string returned by
        get_content_type().
        r�rr�r�s  r�get_content_subtypezMessage.get_content_subtypeur�rc��|jS)aReturn the `default' content type.

        Most messages have a default content type of text/plain, except for
        messages that are subparts of multipart/digest containers.  Such
        subparts have a default content type of message/rfc822.
        �rcrhs rr�zMessage.get_default_type~s���!�!�!rc��||_y)z�Set the `default' content type.

        ctype should be either "text/plain" or "message/rfc822", although this
        is not enforced.  The default content type is not stored in the
        Content-Type header.
        Nr�r�s  r�set_default_typezMessage.set_default_type�s��#��rc�l�t�}|j||�}||ur|Sg}t|�D]K}	|jdd�\}}|j	�}|j	�}|j
||f��Mtj|�}|S#t
$r|j	�}d}Y�IwxYw)Nrrr)	r�r�r7r�rrIr1r�
decode_params)	rdr��headerr�r*�params�pr�r�s	         r�_get_params_preservezMessage._get_params_preserve�s����(�������)���G���N����U�#�		'�A�
��G�G�C��O�	��c��z�z�|���i�i�k��

�M�M�4��+�&�		'��$�$�V�,���
��
�
��w�w�y����
�s�5B�B3�2B3c��t�}|j||�}||ur|S|r |D��cgc]\}}|t|�f��c}}S|Scc}}w)amReturn the message's Content-Type parameters, as a list.

        The elements of the returned list are 2-tuples of key/value pairs, as
        split on the `=' sign.  The left hand side of the `=' is the key,
        while the right hand side is the value.  If there is no `=' sign in
        the parameter the value is the empty string.  The value is as
        described in the get_param() method.

        Optional failobj is the object to return if there is no Content-Type
        header.  Optional header is the header to search instead of
        Content-Type.  If unquote is True, the value is unquoted.
        )r�rr:)rdr�r�r9r�r�r�r�s        r�
get_paramszMessage.get_params�sV���(���*�*�7�F�;���W���N��6<�=�d�a��Q�
�a�(�)�=�=��M��>s�Ac��||vr|S|j||�D]9\}}|j�|j�k(s�(|r
t|�cS|cS|S)a�Return the parameter value if found in the Content-Type header.

        Optional failobj is the object to return if there is no Content-Type
        header, or the Content-Type header has no such parameter.  Optional
        header is the header to search instead of Content-Type.

        Parameter keys are always compared case insensitively.  The return
        value can either be a string, or a 3-tuple if the parameter was RFC
        2231 encoded.  When it's a 3-tuple, the elements of the value are of
        the form (CHARSET, LANGUAGE, VALUE).  Note that both CHARSET and
        LANGUAGE can be None, in which case you should consider VALUE to be
        encoded in the us-ascii charset.  You can usually ignore LANGUAGE.
        The parameter value (either the returned string, or the VALUE item in
        the 3-tuple) is always unquoted, unless unquote is set to False.

        If your application doesn't care whether the parameter was RFC 2231
        encoded, it can turn the return value into a string as follows:

            rawparam = msg.get_param('foo')
            param = email.utils.collapse_rfc2231_value(rawparam)

        )rr0r:)rdrr�r�r9r�r�s       rr�zMessage.get_param�s_��0����N��-�-�g�v�>�	�D�A�q��w�w�y�E�K�K�M�)��(��+�+��H�	��rc�f�t|t�s|r|||f}||vr|j�dk(rd}n|j|�}|j	||��s3|st|||�}n�tj|t|||�g�}nwd}|j||��D]_\}	}
d}|	j�|j�k(rt|||�}n
t|	|
|�}|s|}�Itj||g�}�a||j|�k7r|r|j||�y||=|||<yy)a�Set a parameter in the Content-Type header.

        If the parameter already exists in the header, its value will be
        replaced with the new value.

        If header is Content-Type and has not yet been defined for this
        message, it will be set to "text/plain" and the new parameter and
        value will be appended as per RFC 2045.

        An alternate header can be specified in the header argument, and all
        parameters will be quoted as necessary unless requote is False.

        If charset is specified, the parameter will be encoded according to RFC
        2231.  Optional language specifies the RFC 2231 language, defaulting
        to the empty string.  Both charset and language should be strings.
        r�rZ)r�r�r�r9N)
r"r#r0r�r�r+r�rMrr�)rdrr*r��requoter�languager�r��	old_param�	old_value�append_params            rr�zMessage.set_param�sB��$�%��'�G��h��.�E����&�,�,�.�N�"B� �E��H�H�V�$�E��~�~�e�F�~�3��$�U�E�7�;��!����L���w�?�@�B���E�(,���v�@G�)8�)I�

B�$�	�9�!���?�?�$����
�5�#/��u�g�#F�L�#/�	�9�g�#N�L��(�E�%�N�N�E�<�+@�A�E�

B��D�H�H�V�$�$���#�#�F�E�2���L�$��V��%rc	�*�||vryd}|j||��D]Y\}}|j�|j�k7s�(|st|||�}�8tj	|t|||�g�}�[||j|�k7r	||=|||<yy)a>Remove the given parameter completely from the Content-Type header.

        The header will be re-written in place without the parameter or its
        value. All values will be quoted as necessary unless requote is
        False.  Optional header specifies an alternative to the Content-Type
        header.
        Nrr)rr0r+r�rMr�)rdrr�r�	new_ctyperr�s       rr�zMessage.del_params��������	��O�O�6�7�O�C�	N�D�A�q��w�w�y�E�K�K�M�)� � ,�Q��7� ;�I� )���	�0<�Q��7�0K�0M�!N�I�	N������(�(��V��$�D��L�)rc��|jd�dk(st�|j�dk(r|d=d|d<||vr|||<y|j||��}||=|||<|ddD]\}}|j	||||��y)	aKSet the main type and subtype for the Content-Type header.

        type must be a string in the form "maintype/subtype", otherwise a
        ValueError is raised.

        This method replaces the Content-Type header, keeping all the
        parameters in place.  If requote is False, this leaves the existing
        header's quoting as is.  Otherwise, the parameters will be quoted (the
        default).

        An alternative header can be specified in the header argument.  When
        the Content-Type header is set, we'll always also add a MIME-Version
        header.
        r�rr�zmime-versionr�r�Nr)r.rIr0rr�)rdr�r�rr�rr�s       r�set_typezMessage.set_type&s��� �z�z�#��!�#����<�<�>�^�+��^�$�#(�D�� �����D��L��������@����L���V���1�2�J�	2�D�A�q��N�N�1�a���1�	2rc��t�}|jd|d�}||ur|jd|d�}||ur|Stj|�j	�S)a@Return the filename associated with the payload if present.

        The filename is extracted from the Content-Disposition header's
        `filename' parameter, and it is unquoted.  If that header is missing
        the `filename' parameter, this method falls back to looking for the
        `name' parameter.
        �filename�content-dispositionr�r�)r�r�r�collapse_rfc2231_valuer)rdr�r�rs    r�get_filenamezMessage.get_filenameFs_���(���>�>�*�g�7L�M���w���~�~�f�g�~�F�H��w���N��+�+�H�5�;�;�=�=rc��t�}|jd|�}||ur|Stj|�j	�S)z�Return the boundary associated with the payload if present.

        The boundary is extracted from the Content-Type header's `boundary'
        parameter, and it is unquoted.
        �boundary)r�r�rr�rstrip)rdr�r�rs    r�get_boundaryzMessage.get_boundaryVsB���(���>�>�*�g�6���w���N��+�+�H�5�<�<�>�>rc��t�}|j|d�}||urtjd��g}d}|D]D\}}|j	�dk(r|jdd|zf�d}�2|j||f��F|s|jdd|zf�g}|jD]�\}	}
|	j	�dk(rzg}|D]2\}}
|
dk(r|j|��|j|�d|
����4tj|�}
|j|jj|	|
����|j|	|
f���||_y	)
a�Set the boundary parameter in Content-Type to 'boundary'.

        This is subtly different than deleting the Content-Type header and
        adding a new one with a new boundary parameter via add_header().  The
        main difference is that using the set_boundary() method preserves the
        order of the Content-Type header in the original message.

        HeaderParseError is raised if the message has no Content-Type header.
        r�zNo Content-Type header foundFrz"%s"TrrN)r�rr�HeaderParseErrorr0r1r\r�rMr[r�)rdrr�r��	newparams�foundp�pk�pvr��hr�r�r�r�s              r�set_boundaryzMessage.set_boundarycsc���(���*�*�7�N�C���W���)�)�*H�I�I��	����	+�F�B���x�x�z�Z�'�� � �*�f�x�.?�!@�A���� � �"�b��*�	+��
���j�&�8�*;�<�=��
��M�M�	*�D�A�q��w�w�y�N�*���%�7�D�A�q��B�w����Q������1�%5�6�	7�
 �n�n�U�+���!�!�$�+�+�"@�"@��C�"H�I��!�!�1�a�&�)�	*�#��
rc�T�t�}|jd|�}||ur|St|t�r*|dxsd}	|dj	d�}t||�}	|j	d�|j�S#ttf$r|d}Y�8wxYw#t$r|cYSwxYw)z�Return the charset parameter of the Content-Type header.

        The returned string is always coerced to lower case.  If there is no
        Content-Type header, or if that header has no charset parameter,
        failobj is returned.
        rrzus-asciirr�)	r�r�r"r#r%rr�r�r0)rdr�r�r�pcharsetrvs      r�get_content_charsetzMessage.get_content_charset�s����(���.�.��G�4���g���N��g�u�%��q�z�/�Z�H�
%�#�1�:�,�,�-A�B���h��1��	��N�N�:�&��}�}���� ��.�
%�!�!�*��
%��
�	��N�	�s#� A?�B�?B�B�B'�&B'c�f�|j�D�cgc]}|j|���c}Scc}w)a�Return a list containing the charset(s) used in this message.

        The returned list of items describes the Content-Type headers'
        charset parameter for this message and all the subparts in its
        payload.

        Each item will either be a string (the value of the charset parameter
        in the Content-Type header of that part) or the value of the
        'failobj' parameter (defaults to None), if the part does not have a
        main MIME type of "text", or the charset is not defined.

        The list will contain one string for each part of the message, plus
        one for the container message (i.e. self), so that a non-multipart
        message will still return a list of length 1.
        )�walkr#)rdr��parts   r�get_charsetszMessage.get_charsets�s*�� ?C�i�i�k�J�d��(�(��1�J�J��Js�.c�f�|jd�}|�yt|�dj�}|S)z�Return the message's content-disposition if it exists, or None.

        The return values can be either 'inline', 'attachment' or None
        according to the rfc2183.
        rNr)r�rr0)rdr*�c_ds   r�get_content_dispositionzMessage.get_content_disposition�s8�����.�/���=���%� ��#�)�)�+���
r)r%)FrN)FN)NFr~)Nr�T)r�TNrF)r�T)r�T)4�__name__�
__module__�__qualname__�__doc__r	rerirgrwrvr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�r�r�rrrr r#r'r*�email.iteratorsr%�rrrr�s��
�'�
*� �
�0�

�/�"��:� V�p&�(-B�^�"�	�H�$
#���-�	+�	+�
�",�*��$,�<
"�&�0#�#�"�#��*�,5C�� �DFJ�5:�1%�f%�,2�@>� ?�,#�\�<K�$
�%rc���eZdZd�fd�	Zd�fd�	Zd�Zd�Zd�Zdd�Zhd�Z	d	�Z
d
�Zdd�d�Zdd�d
�Z
d�Zdd�Zdd�Zdd�Zdd�d�Zd�Zd�Zd�Zd�Zd�Z�xZS)�MIMEPartNc�8��|�ddlm}|}t�|�
|�y)Nr)�default)�email.policyr4�superre)rdr[r4�	__class__s   �rrezMIMEPart.__init__�s����>�,��F�
���� rc�b��|�|jn|}|�|j}t�|�
|||�S)aReturn the entire formatted message as a string.

        Optional 'unixfrom', when true, means include the Unix From_ envelope
        header.  maxheaderlen is retained for backward compatibility with the
        base Message class, but defaults to None, meaning that the policy value
        for max_line_length controls the header maximum length.  'policy' is
        passed to the Generator instance used to serialize the message; if it
        is not specified the policy associated with the message instance is
        used.
        )r[�max_line_lengthr6rg)rdrormr[r7s    �rrgzMIMEPart.as_string�s9���!'�����F����!�1�1�L��w� ��<��@�@rc�Z�|j|jjd����S)NT)�utf8�r[)rgr[�clonerhs rrizMIMEPart.__str__�s%���~�~�T�[�[�%6�%6�D�%6�%A�~�B�Brc�J�|jd�}|�dS|jdk(S)NrF�
attachment)r��content_disposition)rdr)s  r�
is_attachmentzMIMEPart.is_attachment�s+���h�h�,�-����u�P��)@�)@�L�)P�Prc#�\K�|j�ry|j�jd�\}}|dk(r||vr|j|�|f��y|dk7s|j	�sy|dk7r0|j�D]}|j
||�Ed{����yd|vr|jd�|f��d}|jd�}|r!|j�D]}|d|k(s�|}n|�|j�}|r|dnd}|�|j
||�Ed{���yy7��7��w)Nr��text�	multipart�related�start�
content-idr)	rAr�r�r/r|�
iter_parts�
_find_bodyr�r�)	rdr&�preferencelist�maintype�subtype�subpart�	candidaterF�subpartss	         rrIzMIMEPart._find_body�sW��������� �1�1�3�9�9�#�>���'��v���.�(�%�+�+�G�4�d�;�;���{�"�$�*;�*;�*=���i���?�?�,�
D���?�?�7�N�C�C�C�
D����&�!�'�'�	�2�D�9�9��	����w�'����?�?�,�
���<�(�E�1� '�I��
����'�'�)�H�'/����T�I�� ����y�.�A�A�A�!�D��
B�s+�BD,�D(�AD,�*7D,�!D*�"D,�*D,c�x�t|�}d}|j||�D]\}}||ks�|}|}|dk(s�|S|S)aReturn best candidate mime part for display as 'body' of message.

        Do a depth first search, starting with self, looking for the first part
        matching each of the items in preferencelist, and return the part
        corresponding to the first item that has a match, or None if no items
        have a match.  If 'related' is not included in preferencelist, consider
        the root part of any multipart/related encountered as a candidate
        match.  Ignore parts with 'Content-Disposition: attachment'.
        Nr)r!rI)rdrJ�	best_prio�body�prior&s      r�get_bodyzMIMEPart.get_bodysY����'�	����/�/�$��?�	�J�D�$��i�� �	����1�9����
	��r>�rC�html�rC�plain�rDrE�rD�alternativec#�K�|j�jd�\}}|dk7s|dk(ry|j�}	|j�}|dk(rt|dk(ro|jd�}|r@d}g}|D]*}|j
d�|k(rd	}�|j|��,|r|Ed{���y|jd
�|Ed{���yg}	|D]^}|j�jd�\}}||f|jvr&|j�s||	vr|	j|��[|���`y#t$rYywxYw7��7�|�w)aReturn an iterator over the non-main parts of a multipart.

        Skip the first of each occurrence of text/plain, text/html,
        multipart/related, or multipart/alternative in the multipart (unless
        they have a 'Content-Disposition: attachment' header) and include all
        remaining subparts in the returned iterator.  When applied to a
        multipart/related, return all parts except the root part.  Return an
        empty iterator when applied to a multipart/alternative or a
        non-multipart.
        r�rDr[NrErFFrGTr)r�r�r�r�r�r�r�r1�pop�_body_typesrA)
rdrKrLr�r�rFr��attachmentsr&�seens
          r�iter_attachmentszMIMEPart.iter_attachments&sl����!�1�1�3�9�9�#�>���'��{�"�g��&>���"�"�$��	��L�L�N�E�
�{�"�w�)�';��N�N�7�+�E���� ��!�1�D��x�x��-��6� $��#�*�*�4�0�	1�
�*�*�*���I�I�a�L��������	�D� $� 5� 5� 7� =� =�c� B��H�g��7�#�t�'7�'7�7��*�*�,���1D����G�$���J�
	��7�	��	��$+��
�sI�>E�D0�AE�(D?�)E�E�A+E�0	D<�9E�;D<�<E�Ec#�bK�|j�r|j�Ed{���yy7��w)z~Return an iterator over all immediate subparts of a multipart.

        Return an empty iterator for a non-multipart.
        N)r|r�rhs rrHzMIMEPart.iter_parts]s.����
�����'�'�)�)�)��)�s�$/�-�/)�content_managerc�^�|�|jj}|j|g|��i|��Sr~)r[rc�get_content�rdrc�args�kws    rrezMIMEPart.get_contentes4���"�"�k�k�9�9�O�*��*�*�4�=�$�=�"�=�=rc�`�|�|jj}|j|g|��i|��yr~)r[rc�set_contentrfs    rrjzMIMEPart.set_contentjs1���"�"�k�k�9�9�O�#��#�#�D�6�4�6�2�6rc�$�|j�dk(r5|j�}||fz}||vrtdj||���g}g}|jD]K\}}|j�j
d�r|j||f��9|j||f��M|r=t|�|j��}	||	_|j|	_
|	g|_
ng|_
||_d|z|d<|�|jd|�yy)NrDzCannot convert {} to {}�content-r<z
multipart/r�r)r�r�rIr�r\r0rFr1r�r[r^r�)
rdrL�disallowed_subtypesr�existing_subtype�keep_headers�part_headersr�r*r&s
          r�_make_multipartzMIMEPart._make_multipartos���$�$�&�+�5�#�7�7�9��"5��
�"B���#6�6� �!:�!A�!A�$�g�"/�0�0������=�=�	3�K�D�%��z�z�|�&�&�z�2��#�#�T�5�M�2��#�#�T�5�M�2�		3�
��4��:�T�[�[�1�D�(�D�M� �M�M�D�M�!�F�D�M��D�M�$��
�+�g�5��^�����N�N�:�x�0� rc�*�|jdd|�y)NrE)r[�mixed�rq�rdrs  r�make_relatedzMIMEPart.make_related�s�����Y�(@�(�Krc�*�|jdd|�y)Nr[)rsrtrus  r�make_alternativezMIMEPart.make_alternative�s�����]�J��Arc�*�|jdd|�y)Nrsr0rtrus  r�
make_mixedzMIMEPart.make_mixed�s�����W�b�(�3r)�_dispc��|j�dk7s|j�|k7rt|d|z��t|�|j��}|j
|i|��|r	d|vr||d<|j
|�y)NrD�make_r<rzContent-Disposition)r�r��getattrr�r[rjr�)rd�_subtyper{rgrhr&s      r�_add_multipartzMIMEPart._add_multipart�s����%�%�'�;�6��(�(�*�h�6�-�G�D�'�H�,�-�/��t�D�z����-������$�%�"�%��*�$�6�*/�D�&�'����D�rc�4�|jdg|��ddi|��y)NrEr{�inline�r��rdrgrhs   r�add_relatedzMIMEPart.add_related�s!������I�C��C�H�C��Crc�0�|jdg|��i|��y)Nr[r�r�s   r�add_alternativezMIMEPart.add_alternative�s������M�7�D�7�B�7rc�4�|jdg|��ddi|��y)Nrsr{r?r�r�s   r�add_attachmentzMIMEPart.add_attachment�s!������G�E�d�E�,�E�"�Erc� �g|_d|_yr~)r\r^rhs r�clearzMIMEPart.clear�s����
���
rc��|jD��cgc](\}}|j�jd�s||f��*c}}|_d|_ycc}}w)Nrl)r\r0rFr^)rd�nr�s   r�
clear_contentzMIMEPart.clear_content�sJ��,0�M�M�B�D�A�q� !���	� 4� 4�Z� @��Q��B��
���
��Bs�-Ar~)FNN))rErVrX)r+r,r-rergrirArIrTr^rarHrerjrqrvrxrzr�r�r�r�r�r��
__classcell__�r7s@rr2r2�s����!�A� C�Q�B�:�(1�K�5�n*�26�>�
26�7�
1�6L�B�4�59��D�8�F��rr2c���eZdZ�fd�Z�xZS)rc�8��t�|�|i|��d|vrd|d<yy)Nr�r�)r6rj)rdrgrhr7s   �rrjzEmailMessage.set_content�s,���
���T�(�R�(���%�#(�D�� �&r)r+r,r-rjr�r�s@rrr�s
���)�)r)NT)r.�__all__rJ�rer��iorr�emailrr�email._policybaser	rr_�email._encoded_wordsrr�r��compiler'rr+r7r:rWrr2rr0rr�<module>r�s���
?��n�
%���	�
� ���&�%�)�
�
�
���	�
�B�J�J�2�3�	� � �D�($�#�>G
%�G
%�T\�w�\�~)�8�)r

Zerion Mini Shell 1.0