ok

Mini Shell

Direktori : /lib64/python3.6/email/__pycache__/
Upload File :
Current File : //lib64/python3.6/email/__pycache__/message.cpython-36.opt-2.pyc

3


 \��@s�ddgZddlZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZmZddlm
Zdd	lmZejZd
Zejd�Zdd
�Zddd�Zdd�Zdd�ZGdd�d�ZGdd�de�ZGdd�de�ZdS)�Message�EmailMessage�N)�BytesIO�StringIO)�utils)�errors)�Policy�compat32)�charset)�decode_bz; z[ \(\)<>@,;:\\"/\[\]\?=]cCs4t|�jd�\}}}|s$|j�dfS|j�|j�fS)N�;)�str�	partition�strip)�param�a�sep�b�r�%/usr/lib64/python3.6/email/message.py�_splitparamsrTcCs�|dk	r�t|�dkr�t|t�rL|d7}tj|d|d|d�}d||fSy|jd�Wn2tk
r�|d7}tj|dd�}d||fSX|s�tj|�r�d	|tj	|�fSd||fSn|SdS)
Nr�*��z%s=%s�asciizutf-8�z%s="%s")
�len�
isinstance�tuplerZencode_rfc2231�encode�UnicodeEncodeError�	tspecials�search�quote)r�valuer#rrr�_formatparam's	
r%cCs�dt|�}g}x�|dd�dkr�|dd�}|jd�}x<|dkrt|jdd|�|jdd|�drt|jd|d�}q:W|dkr�t|�}|d|�}d|kr�|jd�}|d|�j�j�d||dd�j�}|j|j��||d�}qW|S)Nrrr�"z\"r�=)r
�find�countr�indexr�lower�append)�sZplist�end�f�irrr�_parseparamIs 
*
,r1cCs4t|t�r&|d|dtj|d�fStj|�SdS)Nrrr)rrr�unquote)r$rrr�
_unquotevalue]s
r3c@s�eZdZefdd�Zdd�Zdcdd	�Zd
d�Zdddd
�Zdd�Z	dd�Z
dd�Zdd�Zdedd�Z
dfdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zdgd0d1�Zd2d3�Zd4d5�Zdhd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%didJdK�Z&djdLdM�Z'dkdPdQ�Z(dldRdS�Z)dmdTdU�Z*dndVdW�Z+dodXdY�Z,dZd[�Z-dpd\d]�Z.dqd^d_�Z/d`da�Z0ddbl1m2Z2dS)rrcCs:||_g|_d|_d|_d|_d|_|_g|_d|_dS)Nz
text/plain)	�policy�_headers�	_unixfrom�_payload�_charsetZpreambleZepilogue�defects�
_default_type)�selfr4rrr�__init__xszMessage.__init__cCs|j�S)N)�	as_string)r;rrr�__str__�szMessage.__str__FrNcCsJddlm}|dkr|jn|}t�}||d||d�}|j||d�|j�S)Nr)�	GeneratorF)�mangle_from_�maxheaderlenr4)�unixfrom)�email.generatorr?r4r�flatten�getvalue)r;rBrAr4r?�fp�grrrr=�szMessage.as_stringcCs|j�S)N)�as_bytes)r;rrr�	__bytes__�szMessage.__bytes__cCsHddlm}|dkr|jn|}t�}||d|d�}|j||d�|j�S)Nr)�BytesGeneratorF)r@r4)rB)rCrJr4rrDrE)r;rBr4rJrFrGrrrrH�szMessage.as_bytescCst|jt�S)N)rr7�list)r;rrr�is_multipart�szMessage.is_multipartcCs
||_dS)N)r6)r;rBrrr�set_unixfrom�szMessage.set_unixfromcCs|jS)N)r6)r;rrr�get_unixfrom�szMessage.get_unixfromcCsF|jdkr|g|_n.y|jj|�Wntk
r@td��YnXdS)Nz=Attach is not valid on a message with a non-multipart payload)r7r,�AttributeError�	TypeError)r;�payloadrrr�attach�s

zMessage.attachcCs�|j�r(|rdS|dkr|jS|j|S|dk	rPt|jt�rPtdt|j���|j}t|jdd��j�}t|t��rt	j
|�r�|jdd�}|s�y|j|j
dd�d�}Wn tk
r�|jdd�}YnXn6|�ry|jd�}Wn tk
�r|jd�}YnX|�s|S|d	k�r tj|�S|d
k�rbtdj|j���\}}x|D]}|jj||��qFW|S|dk�r�t|�}	t�}
ytj|	|
dd�|
j�Stjk
�r�|SXt|t��r�|S|S)NzExpected list, got %szcontent-transfer-encodingrr�surrogateescaper
�replacezraw-unicode-escapezquoted-printable�base64��
x-uuencode�uuencode�uue�x-uueT)�quiet)rWrXrYrZ)rLr7rrKrP�typer
�getr+rZ_has_surrogatesr�decode�	get_param�LookupError�UnicodeError�quopriZdecodestringr�join�
splitlinesr4Z
handle_defectr�uurE�Error)r;r0r^rQ�cteZbpayloadr$r9ZdefectZin_fileZout_filerrr�get_payload�sV"






zMessage.get_payloadcCspt|d�r:|dkr||_dSt|t�s.t|�}|j|j�}t|d�rT|jdd�|_n||_|dk	rl|j|�dS)Nrr^rrS)�hasattrr7r�Charsetr�output_charsetr^�set_charset)r;rQr
rrr�set_payload/s


zMessage.set_payloadcCs|dkr|jd�d|_dSt|t�s.t|�}||_d|krH|jdd�d|krf|jdd|j�d�n|jd|j��||j�kr�|j|j�|_d|k�r|j	�}y||�Wnjt
k
�r|j}|r�y|jdd	�}Wn tk
r�|j|j
�}YnX|j|�|_|jd|�YnXdS)
Nr
zMIME-Versionz1.0zContent-Typez
text/plain)r
zContent-Transfer-EncodingrrS)�	del_paramr8rrj�
add_headerZget_output_charset�	set_paramZbody_encoder7Zget_body_encodingrPrrark)r;r
rgrQrrrrlCs8


zMessage.set_charsetcCs|jS)N)r8)r;rrr�get_charsetrszMessage.get_charsetcCs
t|j�S)N)rr5)r;rrr�__len__zszMessage.__len__cCs
|j|�S)N)r])r;�namerrr�__getitem__~s	zMessage.__getitem__cCsv|jj|�}|r\|j�}d}x>|jD]4\}}|j�|kr$|d7}||kr$tdj||���q$W|jj|jj||��dS)Nrrz/There may be at most {} {} headers in a message)r4Zheader_max_countr+r5�
ValueError�formatr,�header_store_parse)r;rs�valZ	max_countZlname�found�k�vrrr�__setitem__�szMessage.__setitem__cCsD|j�}g}x,|jD]"\}}|j�|kr|j||f�qW||_dS)N)r+r5r,)r;rs�
newheadersrzr{rrr�__delitem__�szMessage.__delitem__cCs|j�dd�|jD�kS)NcSsg|]\}}|j��qSr)r+)�.0rzr{rrr�
<listcomp>�sz(Message.__contains__.<locals>.<listcomp>)r+r5)r;rsrrr�__contains__�szMessage.__contains__ccsx|jD]\}}|VqWdS)N)r5)r;Zfieldr$rrr�__iter__�szMessage.__iter__cCsdd�|jD�S)NcSsg|]\}}|�qSrr)rrzr{rrrr��sz Message.keys.<locals>.<listcomp>)r5)r;rrr�keys�szMessage.keyscs�fdd��jD�S)Ncsg|]\}}�jj||��qSr)r4�header_fetch_parse)rrzr{)r;rrr��sz"Message.values.<locals>.<listcomp>)r5)r;r)r;r�values�s
zMessage.valuescs�fdd��jD�S)Ncs"g|]\}}|�jj||�f�qSr)r4r�)rrzr{)r;rrr��sz!Message.items.<locals>.<listcomp>)r5)r;r)r;r�items�s
z
Message.itemscCs:|j�}x,|jD]"\}}|j�|kr|jj||�SqW|S)N)r+r5r4r�)r;rs�failobjrzr{rrrr]�s
zMessage.getcCs|jj||f�dS)N)r5r,)r;rsr$rrr�set_raw�szMessage.set_rawcCst|jj��S)N)�iterr5�copy)r;rrr�	raw_items�szMessage.raw_itemscCsLg}|j�}x2|jD](\}}|j�|kr|j|jj||��qW|sH|S|S)N)r+r5r,r4r�)r;rsr�r�rzr{rrr�get_all�s	zMessage.get_allcKstg}xH|j�D]<\}}|dkr2|j|jdd��q|jt|jdd�|��qW|dk	rb|jd|�tj|�||<dS)N�_�-r)r�r,rTr%�insert�	SEMISPACErc)r;�_name�_valueZ_params�partsrzr{rrrroszMessage.add_headercCs^|j�}xPttt|j��|j�D].\}\}}|j�|kr |jj||�|j|<Pq Wt|��dS)N)r+�zip�rangerr5r4rw�KeyError)r;r�r�r0rzr{rrr�replace_header!s$zMessage.replace_headercCsHt�}|jd|�}||kr"|j�St|�dj�}|jd�dkrDdS|S)Nzcontent-typer�/rz
text/plain)�objectr]�get_default_typerr+r))r;�missingr$�ctyperrr�get_content_type4s
zMessage.get_content_typecCs|j�}|jd�dS)Nr�r)r��split)r;r�rrr�get_content_maintypeLszMessage.get_content_maintypecCs|j�}|jd�dS)Nr�r)r�r�)r;r�rrr�get_content_subtypeUszMessage.get_content_subtypecCs|jS)N)r:)r;rrrr�^szMessage.get_default_typecCs
||_dS)N)r:)r;r�rrr�set_default_typegszMessage.set_default_typec	Cs�t�}|j||�}||kr|Sg}xdt|�D]X}y$|jdd�\}}|j�}|j�}Wn tk
rt|j�}d}YnX|j||f�q,Wtj|�}|S)Nr'rr)	r�r]r1r�rrur,rZ
decode_params)	r;r��headerr�r$�params�prsrxrrr�_get_params_preserveps 

zMessage._get_params_preserve�content-typeTcCs8t�}|j||�}||kr|S|r0dd�|D�S|SdS)NcSsg|]\}}|t|�f�qSr)r3)rrzr{rrrr��sz&Message.get_params.<locals>.<listcomp>)r�r�)r;r�r�r2r�r�rrr�
get_params�s
zMessage.get_paramscCsJ||kr|Sx8|j||�D](\}}|j�|j�kr|r>t|�S|SqW|S)N)r�r+r3)r;rr�r�r2rzr{rrrr_�szMessage.get_param�Content-TypercCst|t�r|r|||f}||kr4|j�dkr4d}n
|j|�}|j||d�sv|s^t|||�}q�tj|t|||�g�}nfd}x`|j||d�D]N\}	}
d}|	j�|j�kr�t|||�}nt|	|
|�}|s�|}q�tj||g�}q�W||j|�k�r|�r|j	||�n||=|||<dS)Nzcontent-typez
text/plain)r�r)r�r2)
rrr+r]r_r%r�rcr�r�)r;rr$r��requoter
ZlanguagerTr�Z	old_paramZ	old_valueZappend_paramrrrrp�s2

zMessage.set_paramcCs�||krdSd}xR|j||d�D]@\}}|j�|j�kr |sJt|||�}q tj|t|||�g�}q W||j|�kr�||=|||<dS)Nr)r�r2)r�r+r%r�rcr])r;rr�r�Z	new_ctyper�r{rrrrn�szMessage.del_paramcCs�|jd�dkst�|j�dkr,|d=d|d<||kr@|||<dS|j||d�}||=|||<x(|dd�D]\}}|j||||�qjWdS)Nr�rzcontent-typezmime-versionz1.0zMIME-Version)r�r2)r)rur+r�rp)r;r\r�r�r�r�r{rrr�set_typeszMessage.set_typecCsDt�}|jd|d�}||kr*|jd|d�}||kr6|Stj|�j�S)N�filenamezcontent-dispositionrszcontent-type)r�r_r�collapse_rfc2231_valuer)r;r�r�r�rrr�get_filename&szMessage.get_filenamecCs,t�}|jd|�}||kr|Stj|�j�S)N�boundary)r�r_rr��rstrip)r;r�r�r�rrr�get_boundary6s
zMessage.get_boundarycCs t�}|j|d�}||kr$tjd��g}d}xB|D]:\}}|j�dkr^|jdd|f�d}q2|j||f�q2W|s�|jdd|f�g}x�|jD]�\}	}
|	j�dk�rg}x6|D].\}}
|
dkr�|j|�q�|jd||
f�q�Wtj|�}
|j|j	j
|	|
��q�|j|	|
f�q�W||_dS)	Nzcontent-typezNo Content-Type header foundFr�z"%s"Trz%s=%s)r�r�rZHeaderParseErrorr+r,r5r�rcr4rw)r;r�r�r�Z	newparamsZfoundpZpkZpvr}�hr{r�rzrxrrr�set_boundaryCs2


zMessage.set_boundarycCs�t�}|jd|�}||kr|St|t�rr|dp2d}y|djd�}t||�}Wn ttfk
rp|d}YnXy|jd�Wntk
r�|SX|j�S)Nr
rzus-asciirzraw-unicode-escape)	r�r_rrrr
r`rar+)r;r�r�r
ZpcharsetrHrrr�get_content_charsetqs 
zMessage.get_content_charsetcs�fdd�|j�D�S)Ncsg|]}|j���qSr)r�)r�part)r�rrr��sz(Message.get_charsets.<locals>.<listcomp>)�walk)r;r�r)r�r�get_charsets�szMessage.get_charsetscCs*|jd�}|dkrdSt|�dj�}|S)Nzcontent-dispositionr)r]rr+)r;r$�c_drrr�get_content_disposition�s

zMessage.get_content_disposition)r�)FrN)FN)NF)N)N)N)Nr�T)Nr�T)r�TNrF)r�T)r�T)N)N)N)N)3�__name__�
__module__�__qualname__r	r<r>r=rIrHrLrMrNrRrhrmrlrqrrrtr|r~r�r�r�r�r�r]r�r�r�ror�r�r�r�r�r�r�r�r_rprnr�r�r�r�r�r�r�Zemail.iteratorsr�rrrrris`


Z
/


				

!
2

 


.


cs�eZdZd3dd�Zd4�fdd�	Zdd�Zd	d
�Zdd�Zd6dd�Zd7d8d9d:hZ	dd�Z
dd�Zdd�dd�Zdd�dd�Z
dd�Zd;d d!�Zd<d"d#�Zd=d$d%�Zdd&�d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z�ZS)>�MIMEPartNcCs(|dkrddlm}|}tj||�dS)Nr)�default)Zemail.policyr�rr<)r;r4r�rrrr<�szMIMEPart.__init__Fcs0|dkr|jn|}|dkr |j}t�j||d�S)N)rAr4)r4Zmax_line_length�superr=)r;rBrAr4)�	__class__rrr=�szMIMEPart.as_stringcCs|j|jjdd�d�S)NT)�utf8)r4)r=r4Zclone)r;rrrr>�szMIMEPart.__str__cCs |jd�}|dkrdS|jdkS)Nzcontent-dispositionF�
attachment)r]Zcontent_disposition)r;r�rrr�
is_attachment�s
zMIMEPart.is_attachmentc	cs|j�rdS|j�jd�\}}|dkrB||kr>|j|�|fVdS|dkrNdS|dkr~x"|j�D]}|j||�EdHq`WdSd|kr�|jd�|fVd}|jd�}|r�x"|j�D]}|d|kr�|}Pq�W|dkr�|j�}|r�|dnd}|dk	�r|j||�EdHdS)Nr��text�	multipart�related�startz
content-idr)r�r�r�r*�
iter_parts�
_find_bodyr_rh)	r;r��preferencelist�maintype�subtypeZsubpart�	candidater�Zsubpartsrrrr��s6

zMIMEPart._find_bodyr��html�plaincCsDt|�}d}x2|j||�D]"\}}||kr|}|}|dkrPqW|S)Nr)rr�)r;r�Z	best_prioZbodyZprior�rrr�get_body�s
zMIMEPart.get_bodyr�r��alternativec	cs|j�jd�\}}|dks"|dkr&dS|j�j�}|dkr�|dkr�|jd�}|r�d}g}x*|D]"}|jd�|krvd}q^|j|�q^W|r�|EdHdS|jd	�|EdHdSg}xP|D]H}|j�jd�\}}||f|jkr�|j	�r�||kr�|j|�q�|Vq�WdS)
Nr�r�r�r�r�Fz
content-idTr)
r�r�rhr�r_r]r,�pop�_body_typesr�)	r;r�r�r�r�ryZattachmentsr��seenrrr�iter_attachmentss6






zMIMEPart.iter_attachmentsccs|j�dkr|j�EdHdS)Nr�)r�rh)r;rrrr�4szMIMEPart.iter_parts)�content_managercOs"|dkr|jj}|j|f|�|�S)N)r4r��get_content)r;r��args�kwrrrr�<szMIMEPart.get_contentcOs&|dkr|jj}|j|f|�|�dS)N)r4r��set_content)r;r�r�r�rrrr�AszMIMEPart.set_contentc
Cs�|j�dkr6|j�}||f}||kr6tdj||���g}g}x>|jD]4\}}|j�jd�rl|j||f�qF|j||f�qFW|r�t|�|j	d�}	||	_|j
|	_
|	g|_
ng|_
||_d||d<|dk	r�|jd|�dS)Nr�zCannot convert {} to {}zcontent-)r4z
multipart/zContent-Typer�)r�r�rurvr5r+�
startswithr,r\r4r7rp)
r;r�Zdisallowed_subtypesr�Zexisting_subtypeZkeep_headersZpart_headersrsr$r�rrr�_make_multipartFs,


zMIMEPart._make_multipartcCs|jdd|�dS)Nr�r��mixed)r�r�)r�)r;r�rrr�make_relatedaszMIMEPart.make_relatedcCs|jdd|�dS)Nr�r�)r�)r�)r;r�rrr�make_alternativedszMIMEPart.make_alternativecCs|jdf|�dS)Nr�)r�)r;r�rrr�
make_mixedgszMIMEPart.make_mixed)�_dispcOsf|j�dks|j�|kr(t|d|��t|�|jd�}|j||�|rXd|krX||d<|j|�dS)Nr�Zmake_)r4zcontent-dispositionzContent-Disposition)r�r��getattrr\r4r�rR)r;Z_subtyper�r�r�r�rrr�_add_multipartjszMIMEPart._add_multipartcOs|jd|�ddi|��dS)Nr�r�Zinline)r�)r�)r;r�r�rrr�add_relatedtszMIMEPart.add_relatedcOs|jd|�|�dS)Nr�)r�)r�)r;r�r�rrr�add_alternativewszMIMEPart.add_alternativecOs|jd|�ddi|��dS)Nr�r�r�)r�)r�)r;r�r�rrr�add_attachmentzszMIMEPart.add_attachmentcCsg|_d|_dS)N)r5r7)r;rrr�clear}szMIMEPart.clearcCsdd�|jD�|_d|_dS)NcSs&g|]\}}|j�jd�s||f�qS)zcontent-)r+r�)r�nr{rrrr��sz*MIMEPart.clear_content.<locals>.<listcomp>)r5r7)r;rrr�
clear_content�szMIMEPart.clear_content)N)FNN�r�r�r�)r�)r�r�)r�r�)r�r�)r�r�)N)N)N)r�r�r�r<r=r>r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rr)r�rr��s0

.



r�cseZdZ�fdd�Z�ZS)rcs"t�j||�d|krd|d<dS)NzMIME-Versionz1.0)r�r�)r;r�r�)r�rrr��szEmailMessage.set_content)r�r�r�r�r�rr)r�rr�s)NT)�__all__�rererb�iorrZemailrrZemail._policybaserr	r
r8Zemail._encoded_wordsrrjr��compiler!rr%r1r3rr�rrrrr�<module>s4


"NW

Zerion Mini Shell 1.0