AlkantarClanX12

Your IP : 18.222.20.30


Current Path : /opt/alt/python39/lib64/python3.9/email/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/email/__pycache__/message.cpython-39.opt-2.pyc

a

R�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/python39/lib64/python3.9/email/message.py�_splitparamsrTcCs�|dur�t|�dkr�t|t�rL|d7}t�|d|d|d�}d||fSz|�d�Wn4ty�|d7}t�|dd�}d||fYS0|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|vr�|�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}|dur|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}|dur|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_unixfromcCsD|jdur|g|_n,z|j�|�Wnty>td��Yn0dS)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|dur|jS|j|S|durNt|jt�sNtdt|j���|j}t|�dd����}t|t�r�t	�
|�r�|�dd�}|s�z|�|�
dd�d�}Wq�ty�|�dd�}Yq�0n0|r�z|�d�}Wnty�|�d�}Yn0|�s|S|d	k�rt�|�S|d
k�rRtd�|����\}}|D]}|j�||��q8|S|dv�r�t|�}	t�}
ztj|	|
d
d�|
��WStj�y�|YS0t|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:|dur||_dSt|t�s.t|�}|�|j�}t|d�rT|�dd�|_n||_|durl|�|�dS)Nr!rbrrZ)�hasattrr:r�Charsetr!�output_charsetrb�set_charset)r>rXrrrr�set_payload/s


zMessage.set_payloadcCs|dur|�d�d|_dSt|t�s.t|�}||_d|vrH|�dd�d|vrf|jdd|��d�n|�d|���||��kr�|�|j�|_d|v�r|�	�}z||�Wnft
�y|j}|r�z|�dd	�}Wnty�|�|j
�}Yn0|�|�|_|�d|�Yn0dS)
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�vS)NcSsg|]\}}|���qSr)r-��.0r�r�rrr�
<listcomp>�r^z(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��r^z 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]<\}}|dur0|�|�dd��q|�t|�dd�|��q|dur^|�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|�}||ur"|��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�}|�||�}||ur|Sg}t|�D]V}z$|�dd�\}}|��}|��}Wntyp|��}d}Yn0|�||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�}|�||�}||ur|S|r0dd�|D�S|SdS)NcSsg|]\}}|t|�f�qSr)r5r�rrrr��r^z&Message.get_params.<locals>.<listcomp>)r�r�)r>r�r�r4r�r�rrr�
get_params�s
zMessage.get_paramscCsN||vr|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}||vr2|��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�||vr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<||vr@|||<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�}||ur*|�d|d�}||ur6|St�|���S)N�filename�content-dispositionr{r�)r�rcr�collapse_rfc2231_valuer)r>r�r�r�rrr�get_filename&szMessage.get_filenamecCs,t�}|�d|�}||ur|St�|���S)N�boundary)r�rcrr��rstrip)r>r�r�r�rrr�get_boundary6s
zMessage.get_boundarycCst�}|�|d�}||ur$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|�}||ur|St|t�rp|dp2d}z|d�d�}t||�}Wnttfyn|d}Yn0z|�d�Wnty�|YS0|��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��r^z(Message.get_charsets.<locals>.<listcomp>��walk)r>r�rr�r�get_charsets�szMessage.get_charsetscCs*|�d�}|durdSt|�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�rrrrrisd


Z
/


				
�
"�
3

 


.


cs�eZdZd/�fdd�	Zd0�fdd�	Zdd�Zd	d
�Zdd�Zd1dd�Zhd�Z	dd�Z
dd�Zdd�dd�Zdd�dd�Z
dd�Zd2dd�Zd3dd�Zd4d d!�Zdd"�d#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Z�ZS)5�MIMEPartNcs(|durddlm}|}t��|�dS)Nr)�default)Zemail.policyr��superr?)r>r7r���	__class__rrr?�szMIMEPart.__init__Fcs0|dur|jn|}|dur |j}t��|||�Sr@)r7Zmax_line_lengthr�rA)r>rHrFr7r�rrrA�szMIMEPart.as_stringcCs|j|jjdd�d�S)NT)�utf8�r7)rAr7ZclonerBrrrrC�szMIMEPart.__str__cCs |�d�}|durdS|jdkS)Nr�F�
attachment)raZcontent_disposition)r>r�rrr�
is_attachment�s
zMIMEPart.is_attachmentc	cs|��rdS|���d�\}}|dkrB||vr>|�|�|fVdS|dksR|��sVdS|dkr�|��D]}|�||�EdHqfdSd|vr�|�d�|fVd}|�d�}|r�|��D]}|d|kr�|}q�q�|dur�|��}|r�|dnd}|du�r
|�||�EdHdS)Nr��text�	multipart�related�start�
content-idr)	r�r�r�r,rR�
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_prio�bodyZprior�rrr�get_body�s
zMIMEPart.get_body>)r�r�)r�r�)r��alternative)r�r�c
cs"|���d�\}}|dks"|dkr&dS|��}z|��}WntyNYdS0|dkr�|dkr�|�d�}|r�d}g}|D]"}|�d�|kr�d}qz|�|�qz|r�|EdHdS|�d	�|EdHdSg}	|D]L}|���d�\}}||f|j	v�r|�
��s||	v�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|��r|��EdHdSr@)rRrlrBrrrr�=szMIMEPart.iter_parts)�content_managercOs(|dur|jj}|j|g|�Ri|��Sr@)r7r��get_content�r>r��args�kwrrrr�EszMIMEPart.get_contentcOs,|dur|jj}|j|g|�Ri|��dSr@)r7r��set_contentr�rrrr�JszMIMEPart.set_contentc
Cs�|��dkr6|��}||f}||vr6td�||���g}g}|jD]4\}}|���d�rj|�||f�qD|�||f�qD|r�t|�|j	d�}	||	_|j
|	_
|	g|_
ng|_
||_d||d<|dur�|�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_multipartOs.
�
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)�_dispcOsj|��dks|��|kr(t|d|��t|�|jd�}|j|i|��|r\d|vr\||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 |jdg|�Rddi|��dS)Nr�r�Zinline�r��r>r�r�rrr�add_related}szMIMEPart.add_relatedcOs|jdg|�Ri|��dS)Nr�r�r�rrr�add_alternative�szMIMEPart.add_alternativecOs |jdg|�Rddi|��dS)Nr�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�rrrrr�
__classcell__rrr�rr��s*
7



r�cseZdZ�fdd�Z�ZS)rcs&t�j|i|��d|vr"d|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`