Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib/python3.7/site-packages/future/backports/email/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/future/backports/email/__pycache__/utils.cpython-37.pyc

B

�A�[�7�@sdZddlmZddlmZddlmZddlmZddlmZm	Z	m
Z
ddd	d
ddd
ddddddddgZddlZddl
Z
ejr�de
_ddlZddlZddlZddlZddlmZddlmZmZddlZddlmZddlmZddlmZ ddlm!Z!ddlm"Z"m#Z#m$Z$ddl%m&Z'ddl(m)Z)m*Z*dd l+m,Z,d!Z-d"Z.d"Z/d#Z0d$Z1e
�2d%�Z3e
�2d&�Z4e
�2d'�j5Z6d(d)�Z7dAd+d�Z8d,d�Z9e
�2d-e
j:e
j;B�Z<d.d/�Z=dBd1d�Z>dCd2d
�Z?dDd3d�Z@d4d�ZAd5d�ZBd6d�Zd7d	�ZCdEd8d
�ZDe
�2d9e
j�ZEd:d�ZFdFd=d�ZGdGd?d@�ZHdS)HzMiscellaneous utilities.�)�unicode_literals)�division)�absolute_import)�utils)�bytes�int�str�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�unquoteN)�datetime)�quoter)�StringIO)r)�AddressList)r)rr�
_parsedate_tz)�decodestring)�_bencode�_qencode)�Charsetz, �z
�'z[][\\()<>@,:;".]z[\\"]u'([^�-�]|\A)[�-�]([^�-�]|\Z)cCs|�dd�}|�dd�S)N�ascii�surrogateescape�replace)�encode�decode)�string�original_bytes�r*�M/opt/alt/python37/lib/python3.7/site-packages/future/backports/email/utils.py�	_sanitizeHsr,�utf-8cCs�|\}}|�d�|r�y|�d�Wn8tk
r\t|t�rFt|�}|�|�}d||fSXd}t�|�rpd}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.

    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'.
    r#z%s <%s>r!�"z\\\g<0>z%s%s%s <%s>)
r&�UnicodeEncodeError�
isinstancerr �
header_encode�
specialsre�search�	escapesre�sub)�pair�charset�name�address�encoded_name�quotesr*r*r+r
Ps 




cCst�|�}t|�}|jS)z7Return a list of (REALNAME, EMAIL) for each fieldvalue.)�
COMMASPACE�join�_AddressList�addresslist)�fieldvalues�all�ar*r*r+rrs
a_
  =\?                   # 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 %s�Mon�Tue�Wed�Thu�Fri�Sat�Sun���Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Dec�r���r*)�	timetuple�zoner*r*r+�_format_timetuple_and_zone�sr^Fc	Cs�|dkrt��}|rrt�|�}tjr4|dr4tj}ntj}tt|�d�\}}|dkrZd}nd}d|||df}nt�|�}|r�d	}nd
}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.
    N���ir�-�+z
%s%02d%02d�<�GMTz-0000)	�time�	localtime�daylight�altzone�timezone�divmod�abs�gmtimer^)	�timevalre�usegmt�now�offset�hours�minutes�signr]r*r*r+r�s"

cCsV|��}|r2|jdks$|jtjjkr,td��d}n|jdkrBd}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 datetimercz-0000z%z)r\�tzinforrh�utc�
ValueError�strftimer^)�dtrmrnr]r*r*r+r�s

cCsht��}t�dt�|��}t��}t�d�}|dkr:d}nd|}|dkrRt��}d|||||f}|S)anReturns a string suitable for RFC 2822 compliant Message-ID, e.g:

    <20020201195627.33539.96671@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.
    z%Y%m%d%H%M%Si��Nr!�.z<%s.%s.%s%s@%s>)	rdrvrk�os�getpid�random�	randrange�socket�getfqdn)�idstring�domainrlZutcdate�pid�randint�msgidr*r*r+r�s

cCsjtt|��}|dd�g|dd�\}}|dkrDtj|dd��Stj|dd�dt�tj|d��i�S)Nr_rJrs)�seconds)�listrrrh�	timedelta)�dataZ	_3to2list�dtuple�tzr*r*r+r�scCst|�j}|sdS|dS)N)r!r!r)r>r?)�addr�addrsr*r*r+r�s
cCs`t|�dkr\|�d�r<|�d�r<|dd��dd��dd�S|�d�r\|�d�r\|dd�S|S)	zRemove quotes from a string.rXr.r_z\\�\z\"�<�>)�len�
startswith�endswithr%)rr*r*r+r�scCs&|�td�}t|�dkr"dd|fS|S)z#Decode string according to RFC 2231rKN)�split�TICKr�)�s�partsr*r*r+rs
cCs@t|d|pdd�}|dkr&|dkr&|S|dkr2d}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.
    r!r#)�safe�encodingNz%s'%s'%s)�	url_quote)r�r7�languager*r*r+rsz&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Cst|dd�}g}i}|�d�\}}|�||f�x�|r�|�d�\}}|�d�rTd}nd}t|�}t�|�}|r�|�dd�\}}|dk	r�t|�}|�|g��|||f�q2|�|dt	|�f�q2W|�rpx�|�
�D]�\}}g}d}	|��x2|D]*\}}
}|�rt|
d	d
�}
d}	|�|
�q�Wt	t
�|��}|	�rZt|�\}}}|�|||d|ff�q�|�|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�*TFr8�numz"%s"zlatin-1)r�)�pop�appendr�r�rfc2231_continuation�match�groupr�
setdefaultr�items�sort�url_unquote�EMPTYSTRINGr=r)
�params�
new_params�rfc2231_paramsr8�value�encoded�mor��
continuations�extendedr�r7r�r*r*r+r
sD

r%�us-asciicCs\t|t�rt|�dkrt|�S|\}}}t|d�}yt|||�Stk
rVt|�SXdS)NrYzraw-unicode-escape)r0�tupler�rrr�LookupError)r��errors�fallback_charsetr7r��text�rawbytesr*r*r+r	Us

r_c	Cs|dkrtj�tjj���S|jdk	r.|��S|��dd�|f}t�|�}t�	|�}y tj
|jd�}t�||j�}Wn�t
k
r�|tjt�|�dd��}tjo�|jdk}|r�tjntj}|tj
|d�kr�t�|tj|�}n
t�|�}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.

    Nr_)r�rJr)rs)rrnrhrt�
astimezonersr\rd�mktimerer��	tm_gmtoff�tm_zone�AttributeErrorrkrf�tm_isdstrg�tznamer%)	rw�isdst�tmr��localtm�deltar��dst�gmtoffr*r*r+reks$


re)r-)NFF)F)NN)NN)r%r�)Nr_)I�__doc__�
__future__rrr�futurerZfuture.builtinsrrr�__all__ry�re�PY2�ASCIIrd�base64r{r}Zfuture.backportsrZfuture.backports.urllib.parserr�rr��warnings�iorZ!future.backports.email._parseaddrrr>rrrr�quoprirZ_qdecodeZfuture.backports.email.encodersrrZfuture.backports.email.charsetr r<r��UEMPTYSTRING�CRLFr��compiler2r4r3�_has_surrogatesr,r
r�VERBOSE�
IGNORECASE�ecrer^rrrrrrrr�r
r	rer*r*r*r+�<module>s�


"	
-

	
8


Hacked By AnonymousFox1.0, Coded By AnonymousFox