/
proc
/
52785
/
root
/
usr
/
lib64
/
python3.11
/
email
/
__pycache__
/
File Upload :
llllll
Current File: //proc/52785/root/usr/lib64/python3.11/email/__pycache__/utils.cpython-311.opt-1.pyc
� �Zg�H � �� � d Z g d�ZddlZddlZddlZddlZddlZddlZddlZ ddl mZ ddl mZ ddl mZ ddl mZmZmZ ddlmZ d Zd Zd ZdZdZ ej d � � Z ej d� � ZdZdad� Zd� Zd� Z d� Z!d/d�Z"d� Z#d� Z$dZ%dd�d�Z&d� Z'd� Z(d� Z)d� Z*d0d �Z+d1d!�Z,d2d"�Z-d#� Z.dd�d$�Z/d%� Z0d&� Z1d2d'�Z2 ej d(ej3 � � Z4d)� Z5 d3d,�Z6d4d.�Z7dS )5zMiscellaneous 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[\\"]z/etc/python/email.cfgc �: � t �t � � a t S )z5"Cache implementation for _cached_strict_addr_parsing)�_cached_strict_addr_parsing�_use_strict_email_parsing_impl� � �$/usr/lib64/python3.11/email/utils.py�_use_strict_email_parsingr 7 s � � #�*�&D�&F�&F�#�&�&r c �~ � t t j � d� � � � } | rdS t t � � }|5 ddl}|� dd�� � }|� |� � |� ddd�� � } ddd� � n# 1 swxY w Y n# t $ r Y nw xY w| rdS d S ) z]Returns True if strict email parsing is not disabled by config file or env variable. �(PYTHON_EMAIL_DISABLE_STRICT_ADDR_PARSINGFr N)�#)� interpolation�comment_prefixes�email_addr_parsing)�fallbackT)�bool�os�environ�get�open�_EMAIL_CONFIG_FILE�configparser�ConfigParser� read_file� getboolean�FileNotFoundError)�disabled�filer, �configs r r r ? sE � � �B�J�N�N�#M�N�N�O�O�H�� ��u� z��&�'�'�� � z� z�����!�.�.�"�!(� /� � �F� ���T�"�"�"��(�(�)=�?i�tx�(�y�y�H� z� z� z� z� z� z� z� z� z� z� z���� z� z� z� z��� � � � ��� ���� � ��u��4s$ �B) �A B�B!�$B!�) B6�5B6c �R � | � � � dS # t $ r Y dS w xY w)z;Return True if s may contain surrogate-escaped binary data.FT)�encode�UnicodeEncodeError)�ss r �_has_surrogatesr8 \ s; � � � ��� � � ��u��� � � ��t�t����s � � &�&c �Z � | � dd� � }|� dd� � S )N�utf-8�surrogateescape�replace)r5 �decode)�string�original_bytess r � _sanitizer@ i s. � � �]�]�7�,=�>�>�N�� � ��)�4�4�4r r: c � � | \ }}|� d� � |r� |� d� � d}t � |� � rd}t � d|� � }|�|�|�d|�d�S # t $ rD t |t � � rt |� � }|� |� � }|�d|�d�cY S w xY w|S )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 <�>) r5 � specialsre�search� escapesre�subr6 � isinstance�strr � header_encode)�pair�charset�name�address�quotes�encoded_names r r r u s� � � �M�D�'��N�N�7����� C� C��K�K�� � � � �F�� � ��&�&� ����=�=��T�2�2�D�$*�F�D�D�&�&�&�'�'�'�B�B�� "� 7� 7� 7��'�3�'�'� +�!�'�*�*��"�0�0��6�6�L� ,���g�g�g�6�6�6�6� 7���� �Ns �A8 �8AC�Cc # � K � d}d}t | � � D ]"\ }}|r|d|z fV � d}�|dk rd}�||fV � �#|r|dfV � d S d S )Nr F�\T)� enumerate)�addr�pos�escape�chs r �_iter_escaped_charsrY � s� � � � � �C� �F��T�?�?� � ���R�� ���r� �"�"�"�"��F�F� �4�Z�Z��F�F���)�O�O�O�O� � ��D�k������� r c �8 � d| vr| S d}d}g }t | � � D ]:\ }}|dk r/|�|}�||k r|� | ||� � � |dz }d}�;|t | � � k r|� | |d� � � d� |� � S )z Strip real names between quotes.rC r N� r )rY �append�len�join)rU �start�open_pos�resultrV rX s r �_strip_quoted_realnamesrb � s� � � �$����� �E��H� �F�&�t�,�,� � ���R� ��9�9�������H�$�$��M�M�$�u�X�~�"6�7�7�7��a�������s�4�y�y���� � �d�5�6�6�l�#�#�#� �7�7�6�?�?�r T)�strictc �� � |dk rt � � }|s:t � d� | D � � � � }t |� � }|j S d� | D � � } t | � � } t � | � � }t |� � }t |j � � }d}| D ],}t |� � }|d|� d� � z z }�-t |� � |k rdgS |S )z�Return a list of (REALNAME, EMAIL) or ('','') for each fieldvalue. When parsing fails for a fieldvalue, a 2-tuple of ('', '') is returned in its place. If strict is true, use a strict parser which rejects malformed inputs. Nc 3 �4 K � | ]}t |� � V � �d S )N�rJ ��.0�vs r � <genexpr>zgetaddresses.<locals>.<genexpr>� s( � � � �:�:��c�!�f�f�:�:�:�:�:�:r c �, � g | ]}t |� � ��S r rf rg s r � <listcomp>z getaddresses.<locals>.<listcomp>� s � �/�/�/�a�3�q�6�6�/�/�/r r r[ �,�r r ) r � COMMASPACEr^ �_AddressList�addresslist�_pre_parse_validation�_post_parse_validationrb �countr] )�fieldvaluesrc �all�arU ra �nri s r r r � s � � ��~�~�*�,�,�� � ��o�o�:�:�k�:�:�:�:�:��������}��/�/�;�/�/�/�K�'��4�4�K��?�?�;�'�'�D��T���A� #�A�M� 2� 2�F� �A� � � �� $�A�&�&�� �Q������� ���� �6�{�{�a����z���Mr c � � t | � � } d}t | � � D ]%\ }}|dk r|dz }�|dk r|dz }|dk r dS �&|dk S )Nr �(r[ �)F)rb rY )rU �opensrV rX s r �_check_parenthesisr} � sp � �"�4�(�(�D� �E�&�t�,�,� � ���R� ��9�9��Q�J�E�E� �3�Y�Y��Q�J�E��q�y�y��u�u���Q�J�r c �` � g }| D ](}t |� � sd}|� |� � �)|S )Nz('', ''))r} r\ )�email_header_fields�accepted_valuesri s r rr rr sH � ��O� � "� "��!�!�$�$� ��A����q�!�!�!�!��r c �V � g }| D ]#}d|d v rd}|� |� � �$|S )N�[r[ rn )r\ )�parsed_email_header_tuplesr� ri s r rs rs sG � ��O� (� "� "���!�A�$�;�;��A����q�!�!�!�!��r c � � dg d�| d | d g d�| d dz | d | d | d | d |fz S )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�Decr[ r � � � r )� timetuple�zones r �_format_timetuple_and_zoner� sj � �/�9�9�9�)�A�,�G��!�� 3� 3� 3�3<�Q�<�!�3C� E��!��i��l�I�a�L�)�A�,�� 3� � r Fc �" � | �t j � � } |s|r0t j � | t j j � � }nt j � | � � }|r|� � � }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)�time�datetime� fromtimestamp�timezone�utc�utcfromtimestamp� astimezoner )�timeval� localtime�usegmt�dts r r r s� � �$ ���)�+�+��� 9�F� 9� � � ,� ,�W�h�6G�6K� L� L��� � � /� /�� 8� 8��� � �]�]�_�_�����2�v�&�&�&r c �� � | � � � }|r3| j �| j t j j k rt d� � �d}n| j �d}n| � 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. Nz%usegmt option requires a UTC datetime�GMTz-0000z%z)r� �tzinfor� r� r� � ValueError�strftimer� )r� r� �nowr� s r r r < sy � � �,�,�.�.�C� � !� �9��� �X�->�-B� B� B��D�E�E�E���� �� �����{�{�4� � ��%�c�4�0�0�0r c �� � t t j � � dz � � }t j � � }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 �@ Nr �.z<%d.%d.%d%s@%s>)�intr� r'