Your IP : 18.221.161.43


Current Path : /opt/alt/python35/lib64/python3.5/email/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/email/__pycache__/utils.cpython-35.opt-2.pyc



���]x5�@s;dddddddddd	d
ddd
dgZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	m
Z
ddl	mZmZmZddlmZdZdZdZdZdZejd�Zejd�Zdd�Zdd�Zd d!d�Zd"d�Zejd#ejej B�Z!d$d%�Z"dd&d&d'd�Z#d&d(d�Z$ddd)d�Z%d*d
�Z&d+d
�Z'd,d�Z(d-d�Z)ddd.d�Z*ejd/ej+�Z,d0d�Z-d1d2d3d�Z.dd7d5d6�Z/dS)8�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[\\"]cCs/y|j�dSWntk
r*dSYnXdS)NFT)�encode�UnicodeEncodeError)�s�r�*/opt/alt/python35/lib64/python3.5/utils.py�_has_surrogates3s


rcCs"|jdd�}|jdd�S)Nzutf-8�surrogateescape�replace)r�decode)�stringZoriginal_bytesrrr�	_sanitize@sr!zutf-8c
Cs�|\}}|jd�|r�y|jd�WnJtk
r|t|t�r[t|�}|j|�}d||fSYnBXd}tj|�r�d}tj	d|�}d||||fS|S)N�asciiz%s <%s>r�"z\\\g<0>z%s%s%s <%s>)
rr�
isinstance�strrZ
header_encode�
specialsre�search�	escapesre�sub)Zpair�charset�name�addressZencoded_nameZquotesrrrrLs 


cCs"tj|�}t|�}|jS)N)�
COMMASPACE�join�_AddressList�addresslist)Zfieldvalues�all�arrrrns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 ?=
  cCs�ddddddddg|d	|d
ddd
dddddddddg|dd|d|d|d|d|fS)Nz"%s, %02d %s %04d %02d:%02d:%02d %sZMonZTueZWedZThuZFriZSatZSun��ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDec�r���r)�	timetuple�zonerrr�_format_timetuple_and_zone�s !r;FcCsy|dkrtj�}|s$|rBtjj|tjj�}ntjj|�}|rl|j�}d}t||�S)NF)�time�datetimeZ
fromtimestamp�timezone�utcZutcfromtimestamp�
astimezoner)�timeval�	localtime�usegmt�dtrrrr�scCs|j�}|rK|jdks6|jtjjkrBtd��d}n'|jdkrcd}n|jd�}t||�S)Nz%usegmt option requires a UTC datetimeZGMTz-0000z%z)r9�tzinfor=r>r?�
ValueError�strftimer;)rDrC�nowr:rrrr�s$		cCs�ttj�d�}tj�}tjd�}|dkrFd}n
d|}|dkrhtj�}d|||||f}|S)N�d�@r�.z<%d.%d.%d%s@%s>)�intr<�os�getpid�random�getrandbits�socket�getfqdn)Zidstring�domainrA�pid�randintZmsgidrrrr	�s
	
cCsgt|�^}}|dkr5tj|dd��Stj|dd�dtjtjd|���S)Nr3rE�seconds)rr=r>�	timedelta)�dataZdtuple�tzrrrr�s
cCs!t|�j}|sdS|dS)Nrr)rr)r/r0)�addrZaddrsrrrr�scCs�t|�dkr�|jd�rV|jd�rV|dd�jdd�jdd�S|jd�r�|jd�r�|dd	�S|S)
Nr5r#z\\�\z\"�<�>���r^)�len�
startswith�endswithr)r%rrrr�s&cCs5|jtd�}t|�dkr1dd|fS|S)Nr4)�split�TICKr_)r�partsrrrr�s
cCsctjj|ddd|pd�}|dkr@|dkr@|S|dkrRd}d|||fS)NZsafer�encodingr"z%s'%s'%s)�urllib�parser)rr*�languagerrrr�s$z&^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c
Cs	|dd�}g}i}|jd�\}}|j||f�x�|r|jd�\}}|jd�rzd}nd}t|�}tj|�}|r�|jdd�\}}|dk	r�t|�}|j|g�j|||f�qG|j|dt	|�f�qGW|rx�|j
�D]�\}}g}d}	|j�xH|D]@\}}
}|r�tj
j|
dd	�}
d}	|j|
�qSWt	tj|��}|	r�t|�\}}}|j|||d|ff�q*|j|d|f�q*W|S)
Nr�*TFr+�numz"%s"rezlatin-1)�pop�appendrar�rfc2231_continuation�match�grouprL�
setdefaultr�items�sortrfrg�EMPTYSTRINGr.r)
�paramsZ
new_paramsZrfc2231_paramsr+�value�encoded�morjZ
continuationsZextendedrr*rhrrrrsD		%!
#rzus-asciicCs�t|t�s"t|�dkr,t|�S|\}}}|dkrM|}t|d�}yt|||�SWntk
r�t|�SYnXdS)Nr6zraw-unicode-escape)r$�tupler_r�bytesr%�LookupError)ru�errorsZfallback_charsetr*rh�textZrawbytesrrrr?s"

r5c	Csi|dkr(tjjtjj�j�S|jdk	rA|j�S|j�dd�|f}tj|�}tj	|�}y.tj
d|j�}tj||j�}Wn�t
k
rX|tjtj|�dd��}tjo�|jdk}|rtjntj}|tj
d|�krEtj|tj|�}ntj|�}YnX|jd|�S)Nr5rVr3rrEr^)r=rHr>r?r@rEr9r<�mktimerBrW�	tm_gmtoff�tm_zone�AttributeError�gmtime�daylight�tm_isdst�altzone�tznamer)	rDZisdstZtmrVZlocaltmZdeltarY�dstZgmtoffrrrrBYs$

&rBr^)0�__all__rM�rer<rOrQr=Zurllib.parserfZemail._parseaddrrrr/r
rr
rZ
email.charsetrr-rsZUEMPTYSTRINGZCRLFrc�compiler&r(rr!rr�VERBOSE�
IGNORECASEZecrer;rrr	rrrrr�ASCIIrmrrrBrrrr�<module>sl	
"		8

?>