File: //usr/libexec/oracle-cloud-agent/plugins/osms/email/utils.pyc
a
y4�fYH � @ s� d Z g d�ZddlZddlZddlZddlZddlZddlZddlZ ddl
mZ ddl
mZ
ddl
mZ ddl
mZmZmZ ddlmZ d Zd
Zd
ZdZdZe�d
�Ze�d�ZdZdadd� Zdd� Zdd� Z dd� Z!dFdd�Z"dd� Z#dd� Z$dZ%dd �d!d"�Z&d#d$� Z'd%d&� Z(d'd(� Z)d)d*� Z*dGd,d-�Z+dHd.d/�Z,dId0d1�Z-d2d3� Z.dd �d4d5�Z/d6d7� Z0d8d9� Z1dJd:d;�Z2e�d<ej3�Z4d=d>� Z5dKdAdB�Z6dLdDdE�Z7dS )MzMiscellaneous 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 C s t du rt� a t S )z5"Cache implementation for _cached_strict_addr_parsingN)�_cached_strict_addr_parsing�_use_strict_email_parsing_impl� r r �#/usr/lib64/python3.9/email/utils.py�_use_strict_email_parsing7 s r c C s� t tj�d��} | rdS ztt�}W n ty6 Y nV0 |�@ ddl}|jddd�}|� |� |j
dddd�} W d � n1 s�0 Y | r�dS 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�FileNotFoundError�configparser�ConfigParser� read_file�
getboolean)�disabled�filer) �configr r r r ? s$ �
.r c C s( z| � � W dS ty" Y dS 0 dS )z8Return True if s contains surrogate-escaped binary data.FTN)�encode�UnicodeEncodeError)�sr r r �_has_surrogates\ s
r3 c C s | � dd�}|�dd�S )N�utf-8�surrogateescape�replace)r0 �decode)�string�original_bytesr r r � _sanitizei s r: r4 c C s� | \}}|� d� |r�z|� d� W n: ty^ t|t�rDt|�}|�|�}d||f Y S 0 d}t�|�rrd}t� d|�}d||||f S |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'.
�asciiz%s <%s>r �"z\\\g<0>z%s%s%s <%s>)
r0 r1 �
isinstance�strr �
header_encode�
specialsre�search� escapesre�sub)�pair�charset�name�address�encoded_name�quotesr r r r u s
r c c s\ d}d}t | �D ]8\}}|r0|d| fV d}q|dkr>d}q||fV q|rX|dfV d S )Nr F�\T)� enumerate)�addr�pos�escape�chr r r �_iter_escaped_chars� s rP c C s� d| vr| S d}d}g }t | �D ]D\}}|dkr |du r>|}q ||krX|�| ||� � |d }d}q |t| �k r�|�| |d� � d�|�S )z Strip real names between quotes.r<