Hacked By AnonymousFox

Current Path : /opt/alt/python312/lib64/python3.12/email/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/email/__pycache__/utils.cpython-312.pyc

�

0�f0���dZgd�ZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZddl
mZ
ddl
mZddl
mZmZmZddlmZd	Zd
Zd
ZdZdZej2d
�Zej2d�Zd�Zd�Zd d�Zd�Zd�Z d!d�Z!d"d�Z"d#d�Z#d�Z$d�Z%d�Z&d�Z'd#d�Z(ej2dejR�Z*d�Z+		d$d�Z,d#d�Z-y)%zMiscellaneous utilities.)�collapse_rfc2231_value�
decode_params�decode_rfc2231�encode_rfc2231�
formataddr�
formatdate�format_datetime�getaddresses�
make_msgid�	mktime_tz�	parseaddr�	parsedate�parsedate_tz�parsedate_to_datetime�unquote�N)�quote)�AddressList)r)r
r�
_parsedate_tz)�Charsetz, �z
�'z[][\\()<>@,:;".]z[\\"]c�D�	|j�y#t$rYywxYw)z;Return True if s may contain surrogate-escaped binary data.FT)�encode�UnicodeEncodeError)�ss �2/opt/alt/python312/lib64/python3.12/email/utils.py�_has_surrogatesr3s%��
�	���
�������s��	�c�J�|jdd�}|jdd�S)N�utf-8�surrogateescape�replace)r�decode)�string�original_bytess  r�	_sanitizer%@s(��
�]�]�7�,=�>�N�� � ��)�4�4�c�V�|\}}|jd�|rM	|jd�d}tj|�rd}tj	d|�}|�|�|�d|�d�S|S#t
$r7t
|t�rt|�}|j|�}|�d|�d�cYSwxYw)a�The inverse of parseaddr(), this takes a 2-tuple of the form
    (realname, email_address) and returns the string value suitable
    for an RFC 2822 From, To or Cc header.

    If the first element of pair is false, then the second element is
    returned unmodified.

    The optional charset is the character set that is used to encode
    realname in case realname is not ASCII safe.  Can be an instance of str or
    a Charset-like object which has a header_encode method.  Default is
    'utf-8'.
    �asciir�"z\\\g<0>z <�>)
r�
specialsre�search�	escapesre�subr�
isinstance�strr�
header_encode)�pair�charset�name�address�quotes�encoded_names      rrrLs����M�D�'��N�N�7���	C��K�K�� ��F�� � ��&����=�=��T�2�D�$*�D�&�'�B�B��N��"�	7��'�3�'�!�'�*��"�0�0��6�L� ,�g�6�6�		7�s�A(�(=B(�'B(c�h�tjd�|D��}t|�}|jS)z7Return a list of (REALNAME, EMAIL) for each fieldvalue.c3�2K�|]}t|����y�w)N�r0)�.0�vs  r�	<genexpr>zgetaddresses.<locals>.<genexpr>ps����6�Q�#�a�&�6�s�)�
COMMASPACE�join�_AddressList�addresslist)�fieldvalues�all�as   rr	r	ns*��
�/�/�6�+�6�
6�C��S��A��=�=�r&c	�`�dgd�|d|dgd�|ddz
|d|d|d	|d
|fzS)Nz"%s, %02d %s %04d %02d:%02d:%02d %s)�Mon�Tue�Wed�Thu�Fri�Sat�Sun��)�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Dec�r����)�	timetuple�zones  r�_format_timetuple_and_zonerbusZ��/�9�)�A�,�G��!��	3�3<�Q�<�!�3C�	E��!��i��l�I�a�L�)�A�,��
3��r&c��|�tj�}tjj|tjj�}|r|j�}d}n|s|j
d��}t||�S)a�Returns a date string as specified by RFC 2822, e.g.:

    Fri, 09 Nov 2001 01:08:47 -0000

    Optional timeval if given is a floating-point time value as accepted by
    gmtime() and localtime(), otherwise the current time is used.

    Optional localtime is a flag that when True, interprets timeval, and
    returns a date relative to the local timezone instead of UTC, properly
    taking daylight savings time into account.

    Optional argument usegmt means that the timezone is written out as
    an ascii string, not numeric one (so "GMT" instead of "+0000"). This
    is needed for HTTP, and is only used when localtime==False.
    NF)�tzinfo)�time�datetime�
fromtimestamp�timezone�utc�
astimezoner!r)�timeval�	localtime�usegmt�dts    rrr~sk��$���)�)�+��	�	�	�	(�	(��(�2C�2C�2G�2G�	H�B��
�]�]�_����
�
�Z�Z�t�Z�
$���2�v�&�&r&c��|j�}|rA|j�'|jtjjk7rtd��d}n |j�d}n|j
d�}t||�S)a$Turn a datetime into a date string as specified in RFC 2822.

    If usegmt is True, dt must be an aware datetime with an offset of zero.  In
    this case 'GMT' will be rendered instead of the normal +0000 required by
    RFC2822.  This is to support HTTP headers involving date stamps.
    z%usegmt option requires a UTC datetime�GMTz-0000z%z)r`rdrfrhri�
ValueError�strftimerb)rnrm�nowras    rrr�sn��
�,�,�.�C�
�
�9�9���	�	�X�->�->�-B�-B� B��D�E�E���	���	����{�{�4� ��%�c�4�0�0r&c���ttj�dz�}tj�}t	j
d�}|�d}nd|z}|�t
j�}d|||||fz}|S)a{Returns a string suitable for RFC 2822 compliant Message-ID, e.g:

    <142480216486.20800.16526388040877946887@nightshade.la.mastaler.com>

    Optional idstring if given is a string used to strengthen the
    uniqueness of the message id.  Optional domain if given provides the
    portion of the message id after the '@'.  It defaults to the locally
    defined hostname.
    �d�@r�.z<%d.%d.%d%s@%s>)�intre�os�getpid�random�getrandbits�socket�getfqdn)�idstring�domainrk�pid�randint�msgids      rr
r
�sr���$�)�)�+�c�/�"�G�
�)�)�+�C�� � ��$�G�������>��
�~����!����#�w��&� I�I�E��Lr&c	��t|�}|�tdt|�z��|�^}}|�tj|dd�Stj|dddtjtj
|���i�S)Nz!Invalid date value or format "%s"rMrd)�seconds)rrqr0rfrh�	timedelta)�data�parsed_date_tz�dtuple�tzs    rrr�s���"�4�(�N����<�s�4�y�H�I�I� �K�V�R�	�z�� � �&��!�*�-�-����f�R�a�j�F��$�$�X�%7�%7��%C�D�F�Fr&c�<�t|�j}|sy|dS)z�
    Parse addr into its constituent realname and email address parts.

    Return a tuple of realname and email address, unless the parse fails, in
    which case return a 2-tuple of ('', '').
    )rrr)r@rA)�addr�addrss  rrr�s#��
���*�*�E�����8�Or&c��t|�dkDrn|jd�r6|jd�r%|ddjdd�jdd�S|jd�r|jd�r|ddS|S)	zRemove quotes from a string.r[r)���z\\�\z\"�<r*)�len�
startswith�endswithr!r:s rrr�sr��
�3�x�!�|��>�>�#��3�<�<��#4��q��9�$�$�V�T�2�:�:�5�#�F�F��>�>�#��3�<�<��#4��q��9���Jr&c�X�|jtd�}t|�dkrdd|fS|S)z#Decode string according to RFC 2231rNN)�split�TICKr�)r�partss  rrr�s.��
�G�G�D�!��E�
�5�z�Q���T�1�}���Lr&c�v�tjj|d|xsd��}|�|�|S|�d}|�d|�d|��S)z�Encode string according to RFC 2231.

    If neither charset nor language is given, then s is returned as-is.  If
    charset is given but not language, the string is encoded using the empty
    string for language.
    rr()�safe�encodingr)�urllib�parser)rr3�languages   rrr�sK��	�����1�2��0B�7��C�A���8�+������� �(�A�.�.r&z&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c��|dg}i}|ddD]�\}}|jd�}t|�}tj|�}|rG|j	dd�\}}|�t|�}|j
|g�j|||f���|j|dt|�zf���|r�|j�D]�\}}g}d}	|j�|D]<\}}
}|r#tjj|
d	�
�}
d}	|j|
��>ttj|��}|	r)t|�\}}}|j|||d|zff���|j|d|zf���|S)zDecode parameters list according to RFC 2231.

    params is a sequence of 2-tuples containing (param name, string value).
    rr[N�*r4�numz"%s"Fzlatin-1)r�T)r�r�rfc2231_continuation�match�grouprx�
setdefault�appendr�items�sortr�r��EMPTYSTRINGr?r)
�params�
new_params�rfc2231_paramsr4�value�encoded�mor��
continuations�extendedrr3r�s
             rrrs���
��)��J��N��a�b�z���e��-�-��$������
!�
'�
'��
-��
������/�I�D�#����#�h���%�%�d�B�/�6�6��U�G�7L�M����t�V�e�E�l�%:�;�<�"��#1�#7�#7�#9��D�-��E��H���� �$1���Q������,�,�Q��,�C�A�#�H����Q��$1��+�*�*�5�1�2�E��+9�%�+@�(���5��!�!�4�'�8�V�e�^�)L�"M�N��!�!�4��%��"8�9�/$:�0�r&c���t|t�rt|�dk7rt|�S|\}}}|�|}t	|d�}	t|||�S#t$rt|�cYSwxYw)Nr\zraw-unicode-escape)r/�tupler�r�bytesr0�LookupError)r��errors�fallback_charsetr3r��text�rawbytess       rrr4st���e�U�#�s�5�z�Q���u�~��$��G�X�t���#���T�/�0�H���8�W�f�-�-�����t�}���s�A�A%�$A%c��|�ddl}|jddd��|�tjj�}|j	�S)a}Return local time as an aware datetime object.

    If called without arguments, return current time.  Otherwise *dt*
    argument should be a datetime instance, and it is converted to the
    local time zone according to the system time zone database.  If *dt* is
    naive (that is, dt.tzinfo is None), it is assumed to be in local time.
    The isdst parameter is ignored.

    Nrz$The 'isdst' parameter to 'localtime'z>{name} is deprecated and slated for removal in Python {remove})r\�)�message�remove)�warnings�_deprecatedrfrsrj)rn�isdstr�s   rrlrlNsP��
������2�T��	�	�

�z�
�
�
�
"�
"�
$��
�=�=�?�r&)r)NFF)F)NN)r!zus-ascii).�__doc__�__all__ry�rerer{r}rf�urllib.parser��email._parseaddrrrr@rr
rr�
email.charsetrr>r��UEMPTYSTRING�CRLFr��compiler+r-rr%rr	rbrrr
rrrrr�ASCIIr�rrrlr_r&r�<module>r�s���
���$
�	��
�
���"�8�&�C�C�"�
�
�����
��
��
�R�Z�Z�+�
,�
��B�J�J�x� �	�	�5��D��'�:1�&�.F�
���/�"�r�z�z�"K��H�H���.�`*3�,6��4r&

Hacked By AnonymousFox1.0, Coded By AnonymousFox