Mini Shell

Direktori : /proc/self/root/lib64/python3.9/email/__pycache__/
Upload File :
Current File : //proc/self/root/lib64/python3.9/email/__pycache__/utils.cpython-39.pyc

a

X�ZgYH�@s�dZgd�ZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZddl
mZ
ddl
mZddl
mZmZmZddlmZd	Zd
Zd
ZdZdZe�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.cfgcCstdurt�atS)z5"Cache implementation for _cached_strict_addr_parsingN)�_cached_strict_addr_parsing�_use_strict_email_parsing_impl�rr�#/usr/lib64/python3.9/email/utils.py�_use_strict_email_parsing7srcCs�ttj�d��}|rdSztt�}Wnty6YnV0|�@ddl}|jddd�}|�	|�|j
dddd�}Wd�n1s�0Y|r�dSd	S)
z]Returns True if strict email parsing is not disabled by
    config file or env variable.
    Z(PYTHON_EMAIL_DISABLE_STRICT_ADDR_PARSINGFrN)�#)Z
interpolationZcomment_prefixesZemail_addr_parsing)�fallbackT)�bool�os�environ�get�open�_EMAIL_CONFIG_FILE�FileNotFoundError�configparser�ConfigParserZ	read_fileZ
getboolean)�disabled�filer%Zconfigrrrr?s$�
.rcCs(z|��WdSty"YdS0dS)z8Return True if s contains surrogate-escaped binary data.FTN)�encode�UnicodeEncodeError)�srrr�_has_surrogates\s
r,cCs|�dd�}|�dd�S)N�utf-8�surrogateescape�replace)r)�decode)�stringZoriginal_bytesrrr�	_sanitizeisr2r-cCs�|\}}|�d�|r�z|�d�Wn:ty^t|t�rDt|�}|�|�}d||fYS0d}t�|�rrd}t�	d|�}d||||fS|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>)
r)r*�
isinstance�strrZ
header_encode�
specialsre�search�	escapesre�sub)Zpair�charset�name�addressZencoded_nameZquotesrrrrus 




rccs\d}d}t|�D]8\}}|r0|d|fVd}q|dkr>d}q||fVq|rX|dfVdS)NrF�\T)�	enumerate)�addr�pos�escape�chrrr�_iter_escaped_chars�srDcCs�d|vr|Sd}d}g}t|�D]D\}}|dkr |dur>|}q ||krX|�|||��|d}d}q |t|�kr�|�||d��d�|�S)z Strip real names between quotes.r4rN�r)rD�append�len�join)r@�startZopen_pos�resultrArCrrr�_strip_quoted_realnames�s rKT)�strictcCs�|dkrt�}|s4t�dd�|D��}t|�}|jSdd�|D�}t|�}t�|�}t|�}t|j�}d}|D]}t|�}|d|�d�7}qnt	|�|kr�d	gS|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.
    Ncss|]}t|�VqdS)N�r6��.0�vrrr�	<genexpr>��zgetaddresses.<locals>.<genexpr>cSsg|]}t|��qSrrMrNrrr�
<listcomp>�rRz getaddresses.<locals>.<listcomp>rrE�,�rr)
r�
COMMASPACErH�_AddressList�addresslist�_pre_parse_validation�_post_parse_validationrK�countrG)ZfieldvaluesrL�all�ar@rJ�nrPrrrr�s$

rcCsVt|�}d}t|�D]8\}}|dkr.|d7}q|dkr|d8}|dkrdSq|dkS)Nr�(rE�)F)rKrD)r@ZopensrArCrrr�_check_parenthesis�s
racCs(g}|D]}t|�sd}|�|�q|S)Nz('', ''))rarF)Zemail_header_fields�accepted_valuesrPrrrrYsrYcCs,g}|D]}d|dvrd}|�|�q|S)N�[rErU)rF)Zparsed_email_header_tuplesrbrPrrrrZ
srZc	CsHdgd�|d|dgd�|dd|d|d|d	|d
|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %s)ZMonZTueZWedZThuZFriZSatZSun��)ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecrEr���r)�	timetuple�zonerrr�_format_timetuple_and_zones
��rkFcCsR|durt��}|s|r,tj�|tjj�}ntj�|�}|rH|��}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�datetimeZ
fromtimestamp�timezone�utcZutcfromtimestamp�
astimezoner)�timeval�	localtime�usegmt�dtrrrrsrcCsV|��}|r2|jdus$|jtjjkr,td��d}n|jdurBd}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 datetimeZGMTz-0000z%z)ri�tzinformrnro�
ValueError�strftimerk)rtrs�nowrjrrrr<s

rcCs^tt��d�}t��}t�d�}|dur0d}nd|}|durHt��}d|||||f}|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>)�intrlr�getpid�random�getrandbits�socket�getfqdn)Zidstring�domainrq�pid�randintZmsgidrrrr	Os

r	cCsNt|��^}}|dur(tj|dd��Stj|dd�dt�tj|d��i�S)Nrdru��seconds)rrmrn�	timedelta)�dataZdtuple�tzrrrrfs�rcCs�|dkrt�}|s,t|�j}|s$dS|dSt|t�r>|d}t|t�sLdSt|g�d}tt|�j�}|rxt|�dkr|dS|dS)a
    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 ('', '').

    If strict is True, use a strict parser which rejects malformed inputs.
    NrUrrE)	rrWrXr5�listr6rYrZrG)r@rL�addrsrrrrns 


rcCs`t|�dkr\|�d�r<|�d�r<|dd��dd��dd�S|�d�r\|�d�r\|dd�S|S)	zRemove quotes from a string.rEr4���z\\r>z\"�<�>)rG�
startswith�endswithr/rMrrrr�srcCs&|�td�}t|�dkr"dd|fS|S)z#Decode string according to RFC 2231reN)�split�TICKrG)r+�partsrrrr�s
rcCsDtjj|d|pdd�}|dur*|dur*|S|dur6d}d|||fS)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.
    rr3)�safe�encodingNz%s'%s'%s)�urllib�parser)r+r;�languagerrrr�srz&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Cs@|dg}i}|dd�D]x\}}|�d�}t|�}t�|�}|r||�dd�\}}|durbt|�}|�|g��|||f�q|�|dt|�f�q|�r<|�	�D]�\}}g}d}	|�
�|D],\}}
}|r�tjj|
d	d
�}
d}	|�|
�q�tt
�|��}|	�r(t|�\}}}|�|||d|ff�q�|�|d|f�q�|S)zDecode parameters list according to RFC 2231.

    params is a sequence of 2-tuples containing (param name, string value).
    rrEN�*r<�numz"%s"Fzlatin-1)r�T)r�r�rfc2231_continuation�match�groupr|�
setdefaultrFr�items�sortr�r��EMPTYSTRINGrHr)
�params�
new_paramsZrfc2231_paramsr<�value�encoded�mor�Z
continuationsZextendedr+r;r�rrrr�s8


rr/�us-asciicCslt|t�rt|�dkrt|�S|\}}}|dur4|}t|d�}zt|||�WStyft|�YS0dS)Nrfzraw-unicode-escape)r5�tuplerGr�bytesr6�LookupError)r��errorsZfallback_charsetr;r��textZrawbytesrrrr�s

rr�c	Cs|durtj�tjj���S|jdur.|��S|��dd�|f}t�|�}t�	|�}z tj
|jd�}t�||j�}Wn~t
y�|tjt�|�dd��}tjo�|jdk}|r�tjntj}|tj
|d�kr�t�|tj|�}n
t�|�}Yn0|j|d�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.
    In this case, a positive or zero value for *isdst* causes localtime to
    presume initially that summer time (for example, Daylight Saving Time)
    is or is not (respectively) in effect for the specified time.  A
    negative value for *isdst* causes the localtime() function to attempt
    to divine whether summer time is in effect for the specified time.

    Nr�r�rdr)ru)rmrxrnrorprurirl�mktimerrr��	tm_gmtoff�tm_zone�AttributeError�gmtime�daylight�tm_isdst�altzone�tznamer/)	rtZisdstZtmr�ZlocaltmZdeltar��dstZgmtoffrrrrrs$


rr)r-)NFF)F)NN)NN)r/r�)Nr�)8�__doc__�__all__r�rerlr~r�rm�urllib.parser�Zemail._parseaddrrrrWr
rr
rZ
email.charsetrrVr�ZUEMPTYSTRINGZCRLFr��compiler7r9r#rrrr,r2rrDrKZsupports_strict_parsingrrarYrZrkrrr	rrrrr�ASCIIr�rrrrrrrr�<module>sf



!1
	


$
�0�


Zerion Mini Shell 1.0