Your IP : 3.22.68.228


Current Path : /opt/alt/python38/lib64/python3.8/email/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/email/__pycache__/message.cpython-38.opt-2.pyc

U

i�f��@s�ddgZddlZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZmZddlm
Zdd	lmZejZd
Ze�d�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|��d�\}}}|s$|��dfS|��|��fS)N�;)�str�	partition�strip)�param�a�sep�b�r�2/opt/alt/python38/lib64/python3.8/email/message.py�_splitparamsrTcCs�|dk	r�t|�dkr�t|t�rL|d7}t�|d|d|d�}d||fSz|�d�Wn6tk
r�|d7}t�|dd�}d||fYSX|s�t�|�r�d	|t�	|�fSd||fSn|SdS)
Nr�*���%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}|dd�dkr�|dd�}|�d�}|dkrp|�dd|�|�dd|�drp|�d|d�}q6|dkr�t|�}|d|�}d|kr�|�d�}|d|�����d||dd���}|�|���||d�}q|S)Nr
rr�"z\"r�=)r�find�countr�indexr�lower�append)�sZplist�end�f�irrr�_parseparamIs 
(
,r3cCs4t|t�r&|d|dt�|d�fSt�|�SdS)Nrrr)rr r�unquote)r&rrr�
_unquotevalue]s
r5c@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)N�
text/plain)	�policy�_headers�	_unixfrom�_payload�_charsetZpreambleZepilogue�defects�
_default_type)�selfr7rrr�__init__xszMessage.__init__cCs|��S�N)�	as_string�r>rrr�__str__�szMessage.__str__FrNcCsJddlm}|dkr|jn|}t�}||d||d�}|j||d�|��S)Nr)�	GeneratorF)�mangle_from_�maxheaderlenr7��unixfrom)�email.generatorrDr7r�flatten�getvalue)r>rHrFr7rD�fp�grrrrA�s�zMessage.as_stringcCs|��Sr@)�as_bytesrBrrr�	__bytes__�szMessage.__bytes__cCsHddlm}|dkr|jn|}t�}||d|d�}|j||d�|��S)Nr)�BytesGeneratorF)rEr7rG)rIrPr7rrJrK)r>rHr7rPrLrMrrrrN�szMessage.as_bytescCst|jt�Sr@)rr:�listrBrrr�is_multipart�szMessage.is_multipartcCs
||_dSr@�r9)r>rHrrr�set_unixfrom�szMessage.set_unixfromcCs|jSr@rSrBrrr�get_unixfrom�szMessage.get_unixfromcCsF|jdkr|g|_n.z|j�|�Wntk
r@td��YnXdS)Nz=Attach is not valid on a message with a non-multipart payload)r:r.�AttributeError�	TypeError)r>�payloadrrr�attach�s

zMessage.attachcCs�|��r(|rdS|dkr|jS|j|S|dk	rNt|jt�sNtdt|j���|j}t|�dd����}t|t�r�t	�
|�r�|�dd�}|s�z|�|�
dd�d�}Wq�tk
r�|�dd�}Yq�Xn2|r�z|�d�}Wntk
r�|�d�}YnX|�s|S|d	k�rt�|�S|d
k�rVtd�|����\}}|D]}|j�||��q<|S|dk�r�t|�}	t�}
ztj|	|
d
d�|
��WStjk
�r�|YSXt|t��r�|S|S)NzExpected list, got %szcontent-transfer-encodingrr�surrogateescaper�replace�raw-unicode-escapezquoted-printable�base64�)z
x-uuencodeZuuencodeZuuezx-uueT)�quiet)rRr:rrQrW�typer�getr-rZ_has_surrogatesr!�decode�	get_param�LookupError�UnicodeError�quopriZdecodestringr�join�
splitlinesr7Z
handle_defectr�uurK�Error)r>r2rbrX�cteZbpayloadr&r<ZdefectZin_fileZout_filerrr�get_payload�sV"








zMessage.get_payloadcCspt|d�r:|dkr||_dSt|t�s.t|�}|�|j�}t|d�rT|�dd�|_n||_|dk	rl|�|�dS)Nr!rbrrZ)�hasattrr:r�Charsetr!�output_charsetrb�set_charset)r>rXrrrr�set_payload/s


zMessage.set_payloadcCs|dkr|�d�d|_dSt|t�s.t|�}||_d|krH|�dd�d|krf|jdd|��d�n|�d|���||��kr�|�|j�|_d|k�r|�	�}z||�Wnjt
k
�r|j}|r�z|�dd	�}Wn tk
r�|�|j
�}YnX|�|�|_|�d|�YnXdS)
Nr�MIME-Version�1.0�Content-Typer6r
zContent-Transfer-EncodingrrZ)�	del_paramr;rrn�
add_headerZget_output_charset�	set_paramZbody_encoder:Zget_body_encodingrWr!rero)r>rrkrXrrrrpCs:

�
zMessage.set_charsetcCs|jSr@)r;rBrrr�get_charsetrszMessage.get_charsetcCs
t|j�Sr@)rr8rBrrr�__len__zszMessage.__len__cCs
|�|�Sr@)ra�r>�namerrr�__getitem__~s	zMessage.__getitem__cCsr|j�|�}|rX|��}d}|jD]4\}}|��|kr"|d7}||kr"td�||���q"|j�|j�||��dS)Nrrz/There may be at most {} {} headers in a message)r7Zheader_max_countr-r8�
ValueError�formatr.�header_store_parse)r>r{�valZ	max_countZlname�found�k�vrrr�__setitem__�s�zMessage.__setitem__cCs@|��}g}|jD]"\}}|��|kr|�||f�q||_dSr@)r-r8r.)r>r{�
newheadersr�r�rrr�__delitem__�szMessage.__delitem__cCs|��dd�|jD�kS)NcSsg|]\}}|���qSr)r-��.0r�r�rrr�
<listcomp>�sz(Message.__contains__.<locals>.<listcomp>)r-r8rzrrr�__contains__�szMessage.__contains__ccs|jD]\}}|VqdSr@�r8)r>Zfieldr&rrr�__iter__�szMessage.__iter__cCsdd�|jD�S)NcSsg|]\}}|�qSrrr�rrrr��sz Message.keys.<locals>.<listcomp>r�rBrrr�keys�szMessage.keyscs�fdd��jD�S)Ncsg|]\}}�j�||��qSr�r7�header_fetch_parser�rBrrr��s�z"Message.values.<locals>.<listcomp>r�rBrrBr�values�s
�zMessage.valuescs�fdd��jD�S)Ncs"g|]\}}|�j�||�f�qSrr�r�rBrrr��s�z!Message.items.<locals>.<listcomp>r�rBrrBr�items�s
�z
Message.itemscCs:|��}|jD]&\}}|��|kr|j�||�Sq|Sr@)r-r8r7r�)r>r{�failobjr�r�rrrra�s
zMessage.getcCs|j�||f�dSr@)r8r.)r>r{r&rrr�set_raw�szMessage.set_rawcCst|j���Sr@)�iterr8�copyrBrrr�	raw_items�szMessage.raw_itemscCsHg}|��}|jD](\}}|��|kr|�|j�||��q|sD|S|Sr@)r-r8r.r7r�)r>r{r�r�r�r�rrr�get_all�s	zMessage.get_allcKspg}|��D]<\}}|dkr0|�|�dd��q|�t|�dd�|��q|dk	r^|�d|�t�|�||<dS)N�_�-r)r�r.r[r'�insert�	SEMISPACErg)r>�_name�_valueZ_params�partsr�r�rrrrvszMessage.add_headercCs\|��}ttt|j��|j�D]0\}\}}|��|kr|j�||�|j|<qXqt|��dSr@)r-�zip�rangerr8r7r�KeyError)r>r�r�r2r�r�rrr�replace_header!s"zMessage.replace_headercCsHt�}|�d|�}||kr"|��St|�d��}|�d�dkrDdS|S)N�content-typer�/rr6)�objectra�get_default_typerr-r+)r>�missingr&�ctyperrr�get_content_type4s
zMessage.get_content_typecCs|��}|�d�dS)Nr�r�r��split�r>r�rrr�get_content_maintypeLszMessage.get_content_maintypecCs|��}|�d�dS)Nr�rr�r�rrr�get_content_subtypeUszMessage.get_content_subtypecCs|jSr@�r=rBrrrr�^szMessage.get_default_typecCs
||_dSr@r�r�rrr�set_default_typegszMessage.set_default_typec		Cs�t�}|�||�}||kr|Sg}t|�D]X}z$|�dd�\}}|��}|��}Wn tk
rr|��}d}YnX|�||f�q*t�|�}|S)Nr)rr)	r�rar3r�rr}r.rZ
decode_params)	r>r��headerr�r&�params�pr{r�rrr�_get_params_preserveps 

zMessage._get_params_preserver�TcCs8t�}|�||�}||kr|S|r0dd�|D�S|SdS)NcSsg|]\}}|t|�f�qSr)r5r�rrrr��sz&Message.get_params.<locals>.<listcomp>)r�r�)r>r�r�r4r�r�rrr�
get_params�s
zMessage.get_paramscCsN||kr|S|�||�D]0\}}|��|��kr|r@t|�S|Sq|Sr@)r�r-r5)r>rr�r�r4r�r�rrrrc�s
zMessage.get_paramrtrcCs
t|t�s|r|||f}||kr2|��dkr2d}n
|�|�}|j||d�st|s\t|||�}q�t�|t|||�g�}nbd}|j||d�D]N\}	}
d}|	��|��kr�t|||�}nt|	|
|�}|s�|}q�t�||g�}q�||�|�k�r|r�|�	||�n||=|||<dS)Nr�r6)r�r�r�r4)
rr r-rarcr'r�rgr�r�)r>rr&r��requoterZlanguager[r�Z	old_param�	old_valueZappend_paramrrrrw�s6

��zMessage.set_paramcCs�||krdSd}|j||d�D]@\}}|��|��kr|sHt|||�}qt�|t|||�g�}q||�|�kr|||=|||<dS)Nrr�)r�r-r'r�rgra)r>rr�r�Z	new_ctyper�r�rrrru�s
�zMessage.del_paramcCs�|�d�dkst�|��dkr,|d=d|d<||kr@|||<dS|j||d�}||=|||<|dd�D]\}}|�||||�qhdS)Nr�rr�zmime-versionrsrrr�)r+r}r-r�rw)r>r`r�r�r�r�r�rrr�set_typeszMessage.set_typecCsDt�}|�d|d�}||kr*|�d|d�}||kr6|St�|���S)N�filename�content-dispositionr{r�)r�rcr�collapse_rfc2231_valuer)r>r�r�r�rrr�get_filename&szMessage.get_filenamecCs,t�}|�d|�}||kr|St�|���S)N�boundary)r�rcrr��rstrip)r>r�r�r�rrr�get_boundary6s
zMessage.get_boundarycCst�}|�|d�}||kr$t�d��g}d}|D]:\}}|��dkr\|�dd|f�d}q0|�||f�q0|s�|�dd|f�g}|jD]z\}	}
|	��dkr�g}|D].\}}
|
dkr�|�|�q�|�d||
f�q�t�|�}
|�|j	�
|	|
��q�|�|	|
f�q�||_dS)	Nr�zNo Content-Type header foundFr�z"%s"Trr)r�r�rZHeaderParseErrorr-r.r8r�rgr7r)r>r�r�r�Z	newparamsZfoundpZpkZpvr��hr�r�r�r�rrr�set_boundaryCs2


zMessage.set_boundaryc	Cs�t�}|�d|�}||kr|St|t�rr|dp2d}z|d�d�}t||�}Wn ttfk
rp|d}YnXz|�d�Wntk
r�|YSX|��S)Nrrzus-asciirr\)	r�rcrr r!rrdrer-)r>r�r�rZpcharsetrNrrr�get_content_charsetqs 

zMessage.get_content_charsetcs�fdd�|��D�S)Ncsg|]}|����qSr)r�)r��part�r�rrr��sz(Message.get_charsets.<locals>.<listcomp>��walk)r>r�rr�r�get_charsets�szMessage.get_charsetscCs*|�d�}|dkrdSt|�d��}|S)Nr�r)rarr-)r>r&�c_drrr�get_content_disposition�s

zMessage.get_content_dispositionr�)FrN)FN)NF)N)N)N)Nr�T)Nr�T)rtTNrF)r�T)rtT)N)N)N)N)3�__name__�
__module__�__qualname__r	r?rCrArOrNrRrTrUrYrlrqrprxryr|r�r�r�r�r�r�r�rar�r�r�rvr�r�r�r�r�r�r�r�rcrwrur�r�r�r�r�r�r�Zemail.iteratorsr�rrrrrish


Z
/


				
�
"�
3

 


.


cs�eZdZd2dd�Zd3�fdd�	Zdd�Zd	d
�Zdd�Zd4dd�ZddddhZ	dd�Z
dd�Zdd�dd�Zdd�dd�Z
dd�Zd5dd �Zd6d!d"�Zd7d#d$�Zdd%�d&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z�ZS)8�MIMEPartNcCs(|dkrddlm}|}t�||�dS)Nr)�default)Zemail.policyr�rr?)r>r7r�rrrr?�szMIMEPart.__init__Fcs0|dkr|jn|}|dkr |j}t�j||d�S)N)rFr7)r7Zmax_line_length�superrA)r>rHrFr7��	__class__rrrA�szMIMEPart.as_stringcCs|j|jjdd�d�S)NT)�utf8�r7)rAr7ZclonerBrrrrC�szMIMEPart.__str__cCs |�d�}|dkrdS|jdkS)Nr�F�
attachment)raZcontent_disposition)r>r�rrr�
is_attachment�s
zMIMEPart.is_attachmentc	cs|��rdS|���d�\}}|dkrB||kr>|�|�|fVdS|dkrNdS|dkrz|��D]}|�||�EdHq^dSd|kr�|�d�|fVd}|�d�}|r�|��D]}|d|kr�|}q�q�|dkr�|��}|r�|dnd}|dk	�r|�||�EdHdS)Nr��text�	multipart�related�start�
content-idr)r�r�r�r,�
iter_parts�
_find_bodyrcrl)	r>r��preferencelist�maintype�subtypeZsubpart�	candidater�Zsubpartsrrrr��s6

zMIMEPart._find_body�r��html�plaincCsBt|�}d}|�||�D]$\}}||kr|}|}|dkrq>q|S)Nr)rr�)r>r�Z	best_prioZbodyZprior�rrr�get_body�s
zMIMEPart.get_body)r�r�)r�r�)r�r�)r��alternativec
cs$|���d�\}}|dks"|dkr&dS|��}z|��}Wntk
rPYdSX|dkr�|dkr�|�d�}|r�d}g}|D]"}|�d�|kr�d}q||�|�q||r�|EdHdS|�d	�|EdHdSg}	|D]L}|���d�\}}||f|j	k�r|�
��s||	k�r|	�|�q�|Vq�dS)
Nr�r�r�r�r�Fr�Tr)r�r�rlr�rVrcrar.�pop�_body_typesr�)
r>r�r�rXr�r�r�Zattachmentsr��seenrrr�iter_attachmentssD



��
zMIMEPart.iter_attachmentsccs|��dkr|��EdHdS)Nr�)r�rlrBrrrr�=szMIMEPart.iter_parts)�content_managercOs"|dkr|jj}|j|f|�|�Sr@)r7r��get_content�r>r��args�kwrrrr�EszMIMEPart.get_contentcOs&|dkr|jj}|j|f|�|�dSr@)r7r��set_contentr�rrrr�JszMIMEPart.set_contentc
Cs�|��dkr6|��}||f}||kr6td�||���g}g}|jD]4\}}|���d�rj|�||f�qD|�||f�qD|r�t|�|j	d�}	||	_|j
|	_
|	g|_
ng|_
||_d||d<|dk	r�|�d|�dS)Nr�zCannot convert {} to {}�content-r�z
multipart/rtr�)r�r�r}r~r8r-�
startswithr.r`r7r:rw)
r>r�Zdisallowed_subtypesr�Zexisting_subtypeZkeep_headersZpart_headersr{r&r�rrr�_make_multipartOs0
�
zMIMEPart._make_multipartcCs|�dd|�dS)Nr�)r��mixed�r��r>r�rrr�make_relatedjszMIMEPart.make_relatedcCs|�dd|�dS)Nr�)r�r�r�rrr�make_alternativemszMIMEPart.make_alternativecCs|�dd|�dS)Nr�rr�r�rrr�
make_mixedpszMIMEPart.make_mixed)�_dispcOsf|��dks|��|kr(t|d|��t|�|jd�}|j||�|rXd|krX||d<|�|�dS)Nr�Zmake_r�r�zContent-Disposition)r�r��getattrr`r7r�rY)r>Z_subtyper�r�r�r�rrr�_add_multipartss
�zMIMEPart._add_multipartcOs|jd|�ddi|��dS)Nr�r�Zinline)r��r��r>r�r�rrr�add_related}szMIMEPart.add_relatedcOs|jd|�|�dS)Nr�)r�r�r�rrr�add_alternative�szMIMEPart.add_alternativecOs|jd|�ddi|��dS)Nr�r�r�)r�r�r�rrr�add_attachment�szMIMEPart.add_attachmentcCsg|_d|_dSr@�r8r:rBrrr�clear�szMIMEPart.clearcCsdd�|jD�|_d|_dS)NcSs&g|]\}}|���d�s||f�qS)r�)r-r�)r��nr�rrrr��s�z*MIMEPart.clear_content.<locals>.<listcomp>rrBrrr�
clear_content�szMIMEPart.clear_content)N)FNN)r�)N)N)N)r�r�r�r?rArCr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�
__classcell__rrr�rr��s2

�7



r�cseZdZ�fdd�Z�ZS)rcs"t�j||�d|krd|d<dS)Nrrrs)r�r�r�r�rrr��szEmailMessage.set_content)r�r�r�r�rrrr�rr�s)NT)�__all__�rerirf�iorrZemailrrZemail._policybaserr	rr;Zemail._encoded_wordsrrnr��compiler#rr'r3r5rr�rrrrr�<module>s4


"N`

?>