ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/usr/lib64/python3.6/email/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/usr/lib64/python3.6/email/__pycache__/utils.cpython-36.pyc

3

��f�J�@s�dZddddddddd	d
ddd
ddgZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZddl
mZ
ddl
mZddl
mZmZmZddlmZdZdZdZdZdZejd�Zejd�ZdZdadd�Zd d!�Zd"d#�Z d$d%�Z!dId'd�Z"d(d)�Z#d*d+�Z$d,Z%dd-�d.d�Z&d/d0�Z'd1d2�Z(d3d4�Z)ejd5ej*ej+B�Z,d6d7�Z-dJd9d�Z.dKd:d�Z/dLd;d	�Z0d<d�Z1dd-�d=d�Z2d>d�Z3d?d�Z4dMd@d�Z5ejdAej6�Z7dBd�Z8dNdEd�Z9dPdGdH�Z:dS)QzMiscellaneous 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.cfgcCstdkrt�atS)z5"Cache implementation for _cached_strict_addr_parsingN)�_cached_strict_addr_parsing�_use_strict_email_parsing_impl�rr�#/usr/lib64/python3.6/email/utils.py�_use_strict_email_parsing7srcCs�ttjjd��}|rdSytt�}Wntk
r8YnBX|�6ddl}|jdd
d�}|j	|�|j
dddd�}WdQRX|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)ZfallbackT)r)�bool�os�environ�get�open�_EMAIL_CONFIG_FILE�FileNotFoundError�configparserZConfigParserZ	read_fileZ
getboolean)Zdisabled�filer$�configrrrr?s"
rcCs&y|j�dStk
r dSXdS)z8Return True if s contains surrogate-escaped binary data.FTN)�encode�UnicodeEncodeError)�srrr�_has_surrogates\s
r*cCs|jdd�}|jdd�S)Nzutf-8�surrogateescape�replace)r'�decode)�stringZoriginal_bytesrrr�	_sanitizeisr/�utf-8c
Cs�|\}}|jd�|r�y|jd�Wn8tk
r\t|t�rFt|�}|j|�}d||fSXd}tj|�rpd}tj	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.

    Optional charset if given 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�nameZaddressZencoded_nameZquotesrrrrus 




ccs`d}d}xDt|�D]8\}}|r2|d|fVd}q|dkr@d}q||fVqW|r\|dfVdS)NrF�\T)�	enumerate)�addr�pos�escape�chrrr�_iter_escaped_chars�srAcCs�d|kr|Sd}d}g}xPt|�D]D\}}|dkr"|dkr@|}q"||krZ|j|||��|d}d}q"W|t|�kr�|j||d��dj|�S)z Strip real names between quotes.r2rN�r)rA�append�len�join)r=�startZopen_pos�resultr>r@rrr�_strip_quoted_realnames�s rHT)�strictcCs�|dkrt�}|s4tjdd�|D��}t|�}|jSdd�|D�}t|�}tj|�}t|�}t|j�}d}x&|D]}t|�}|d|jd�7}qpWt	|�|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)r4)�.0�vrrr�	<genexpr>�szgetaddresses.<locals>.<genexpr>cSsg|]}t|��qSr)r4)rJrKrrr�
<listcomp>�sz getaddresses.<locals>.<listcomp>rrB�,r)rr)
r�
COMMASPACErE�_AddressList�addresslist�_pre_parse_validation�_post_parse_validationrH�countrD)ZfieldvaluesrI�all�ar=rG�nrKrrrr�s$


cCsXt|�}d}xBt|�D]6\}}|dkr0|d7}q|dkr|d8}|dkrdSqW|dkS)Nr�(rB�)F)rHrA)r=Zopensr>r@rrr�_check_parenthesis�s
rZcCs,g}x"|D]}t|�sd}|j|�q
W|S)Nz('', ''))rZrC)Zemail_header_fields�accepted_valuesrKrrrrRs
rRcCs0g}x&|D]}d|dkrd}|j|�q
W|S)N�[rBr)rr)rC)Zparsed_email_header_tuplesr[rKrrrrS
s
rSa_
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<atom>.*?)         # non-greedy up to the next ?= is the atom
  \?=                   # literal ?=
  cCsfddddddddg|d	|d
ddd
dddddddddg|dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSun��ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecrBr���r)�	timetuple�zonerrr�_format_timetuple_and_zone"srdFcCsR|dkrtj�}|s|r,tjj|tjj�}ntjj|�}|rH|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)�time�datetimeZ
fromtimestamp�timezone�utcZutcfromtimestamp�
astimezoner)�timeval�	localtime�usegmt�dtrrrr+scCsV|j�}|r2|jdks$|jtjjkr,td��d}n|jdkrBd}n
|jd�}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)rb�tzinforfrgrh�
ValueErrorZstrftimerd)rmrl�nowrcrrrrHs

cCs^ttj�d�}tj�}tjd�}|dkr0d}nd|}|dkrHtj�}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>)�intrer�getpid�randomZgetrandbits�socketZgetfqdn)ZidstringZdomainrj�pidZrandintZmsgidrrrr	[s

cCsNt|��^}}|dkr(tj|dd��Stj|dd�dtjtj|d��i�S)Nr]rn)�seconds)rrfrg�	timedelta)�dataZdtuple�tzrrrrrs
cCs�|dkrt�}|s,t|�j}|s$dS|dSt|t�r>|d}t|t�sLdSt|g�d}tt|�j�}|szt|�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.
    NrrrB)rr)rr)rr)	rrPrQr3�listr4rRrSrD)r=rIZaddrsrrrrzs 


cCs`t|�dkr\|jd�r<|jd�r<|dd�jdd�jdd�S|jd�r\|jd�r\|dd	�S|S)
zRemove quotes from a string.rBr2z\\r;z\"�<�>���r�)rD�
startswith�endswithr,)r4rrrr�scCs&|jtd�}t|�dkr"dd|fS|S)z#Decode string according to RFC 2231r^N)�split�TICKrD)r)�partsrrrr�s
cCsDtjj|d|pdd�}|dkr*|dkr*|S|dkr6d}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.
    rr1)Zsafe�encodingNz%s'%s'%s)�urllib�parser)r)r9�languagerrrr�sz&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Csx|dd�}g}i}|jd�\}}|j||f�x�|r�|jd�\}}|jd�rTd}nd}t|�}tj|�}|r�|jdd�\}}|dk	r�t|�}|j|g�j|||f�q2|j|dt	|�f�q2W|�rtx�|j
�D]�\}}g}d}	|j�x6|D].\}}
}|�rtj
j|
d	d
�}
d}	|j|
�q�Wt	tj|��}|	�r^t|�\}}}|j|||d|ff�q�|j|d|f�q�W|S)zDecode parameters list according to RFC 2231.

    params is a sequence of 2-tuples containing (param name, string value).
    Nr�*TFr:�numz"%s"zlatin-1)r�)�poprCr�r�rfc2231_continuation�match�grouprt�
setdefaultr�items�sortr�r��EMPTYSTRINGrEr)
ZparamsZ
new_paramsZrfc2231_paramsr:�valueZencodedZmor�Z
continuationsZextendedr)r9r�rrrr�sD

r,�us-asciicCsjt|t�st|�dkr t|�S|\}}}|dkr6|}t|d�}yt|||�Stk
rdt|�SXdS)Nr_zraw-unicode-escape)r3�tuplerDr�bytesr4�LookupError)r��errorsZfallback_charsetr9r��textZrawbytesrrrr�s

rBc	Cs|dkrtjjtjj�j�S|jdk	r.|j�S|j�dd�|f}tj|�}tj	|�}y tj
|jd�}tj||j�}Wn�t
k
r�|tjtj|�dd��}tjo�|jdk}|r�tjntj}|tj
|d�kr�tj|tj|�}n
tj|�}YnX|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.

    NrB)ryr]r)rnr�)rfrprgrhrirnrbreZmktimerkrzZ	tm_gmtoffZtm_zone�AttributeErrorZgmtimeZdaylightZtm_isdstZaltzoneZtznamer,)	rmZisdstZtmryZlocaltmZdeltar|�dstZgmtoffrrrrks$


rk)r0)NFF)F)NN)NN)r,r�r�)Nr�);�__doc__�__all__r�rerervrwrfZurllib.parser�Zemail._parseaddrrrrPr
rr
rZ
email.charsetrrOr�ZUEMPTYSTRINGZCRLFr��compiler5r7r"rrrr*r/rrArHZsupports_strict_parsingrrZrRrS�VERBOSE�
IGNORECASEZecrerdrrr	rrrrr�ASCIIr�rrrkrrrr�<module>s�



!1

	


$
8


Zerion Mini Shell 1.0