Your IP : 18.216.156.226


Current Path : /opt/alt/python34/lib64/python3.4/email/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/email/__pycache__/contentmanager.cpython-34.pyo

�
e ff)�
@s�ddlZddlZddlZddlZddlmZGdd�d�Ze�Zddd�Zej	de�d	d
�Z
x$dj�D]Zej	ee
�q�Wdd
�Z
x(dj�D]Zej	dee
�q�Wdd�Zej	de�dd�Zdd�Zdd�Zdd�Zdddddddddd�Zejee�dddddddd d!�Zejejje�d"dddddd#d$�Zx'eeefD]Zejee�q�WdS)%�N)�
quoprimimec@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ContentManagercCsi|_i|_dS)N)�get_handlers�set_handlers)�self�r�9/opt/alt/python34/lib64/python3.4/email/contentmanager.py�__init__	s	zContentManager.__init__cCs||j|<dS)N)r)r�key�handlerrrr�add_get_handler
szContentManager.add_get_handlercOs�|j�}||jkr2|j||||�S|j�}||jkrd|j||||�Sd|jkr�|jd|||�St|��dS)N�)Zget_content_typer�get_content_maintype�KeyError)r�msg�args�kwZcontent_type�maintyperrr�get_contentszContentManager.get_contentcCs||j|<dS)N)r)rZtypekeyrrrr�add_set_handlerszContentManager.add_set_handlercOsT|j�dkr!td��n|j||�}|j�|||||�dS)NZ	multipartz"set_content not valid on multipart)r�	TypeError�_find_set_handlerZ
clear_content)rr�objrrrrrr�set_contents

zContentManager.set_contentc	Csd}x�t|�jD]�}||jkr6|j|S|j}t|dd�}|rldj||f�n|}|dkr�|}n||jkr�|j|S||jkr�|j|S|j}||jkr|j|SqWd|jkr�|jdSt|��dS)N�
__module__r
�.)�type�__mro__r�__qualname__�getattr�join�__name__r)	rrrZfull_path_for_error�typZqname�modname�	full_path�namerrrr's&	!		z ContentManager._find_set_handlerN)	r!rrr	rrrrrrrrrrs	r�replacecCs7|jdd�}|jdd�}|j|d|�S)N�decodeT�charset�ASCII�errors)�get_payloadZ	get_paramr')rr*Zcontentr(rrr�get_text_content@sr,�textcCs|jdd�S)Nr'T)r+)rrrr�get_non_text_contentGsr.zaudio image video applicationcCs
|jd�S)Nr)r+)rrrr�get_message_contentMsr/zrfc822 external-bodyzmessage/cCst|jd��S)Nr)�bytesr+)rrrr�%get_and_fixup_unknown_message_contentSsr1�messagecs�dj||f�|d<|r�t|dd�sW|j��fdd�|D�}ny;x4|D],}|jr�|jd�n|||j<qaWWq�tjjk
r�}z,tdj	|j
d|j���|�WYdd}~Xq�XndS)	N�/zContent-Typerr%cs+g|]!}�j�j|g���qSr)Zheader_factoryZheader_source_parse)�.0�header)�mprr�
<listcomp>ds	z _prepare_set.<locals>.<listcomp>zInvalid header: {}�policy)r �hasattrr8Zdefectsr%�emailr*ZHeaderDefect�
ValueError�formatZfold)rr�subtype�headersr5�excr)r6r�_prepare_set_s	

		r@cCs�|dkr!|dk	r!d}n|dk	r:||d<n|dk	re|jd|dddd�n|dk	r~||d<n|dk	r�x-|j�D]\}}|j||�q�WndS)NZ
attachmentzContent-Disposition�filenamer5r&Tz
Content-ID)�	set_param�items)r�dispositionrA�cid�paramsr
�valuerrr�
_finalize_setps	
	

rHcCswg}|dd}xStdt|�|�D]9}||||�}|jtj|�jd��q-Wdj|�S)N��r�asciir
)�range�len�append�binascii�
b2a_base64r'r )�data�max_line_lengthZ
encoded_linesZunencoded_bytes_per_line�iZthislinerrr�_encode_base64�s#rTcs|j|�j�}|jjd���fdd�}dd�}|dkrYyd||�jd�fSWntk
r�YnX|jdkr�tdd	�|D��|jkr�d||�jdd
�fS||dd��}tj	|jd�|j�}t
j|�}	t|�t|	�kr4d
}qYd}t|�dkrY||fSn|dkr}||�jd�}
n�|dkr�||�jdd
�}
no|dkr�tj	||�jd�|j�}
n<|d
kr�t
||�|j�}
ntdj|���||
fS)NrKcs�j|��S)N)r )�lines)�lineseprr�embeded_body�sz"_encode_text.<locals>.embeded_bodycSsdj|�dS)Ns
)r )rUrrr�normal_body�sz!_encode_text.<locals>.normal_body�7bit�8bitcss|]}t|�VqdS)N)rM)r4�xrrr�	<genexpr>�sz_encode_text.<locals>.<genexpr>�surrogateescape�
zlatin-1�base64zquoted-printablez$Unknown content transfer encoding {})�encode�
splitlinesrVr'�UnicodeDecodeErrorZcte_type�maxrRrZbody_encoderOrPrMrTr;r<)�stringr(�cter8rUrWrXZsniffZsniff_qpZsniff_base64rQr)rVr�_encode_text�s@
"	
rfZplainzutf-8c
Cs�t|d||	�t||||j�\}}
|j|
�|jdtjjj||�dd�||d<t	|||||�dS)Nr-r(r&TzContent-Transfer-Encoding)
r@rfr8�set_payloadrBr:r(ZALIASES�getrH)rrdr=r(rerDrArErFr>Zpayloadrrr�set_text_content�s
	
ri�rfc822c		Cs�|dkrtd��n|dkrf|dkrKtdj|���n|dkr]dn|}nN|dkr�|d
kr�td	j|���nd}n|dkr�d}nt|d
||�|j|g�||d<t|||||�dS)N�partialz4message/partial is not supported for Message objectsrjrYrZ�binaryz*message/rfc822 parts do not support cte={}z
external-bodyz1message/external-body parts do not support cte={}r2zContent-Transfer-Encoding)N�7bitz8bitrl)Nrm)r;r<r@rgrH)	rr2r=rerDrArErFr>rrr�set_message_content�s$		
rnr_c

Cs�t||||	�|dkr:t|d|jj�}n||dkrytj|dddddd�}|jd	�}n=|d
kr�|jd	�n!|dkr�|jd	d
�}n|j|�||d<t	|||||�dS)Nr_rRzquoted-printable�istextFr5Z	quotetabsTrKrYrZrlr]zContent-Transfer-Encoding)z8bitzbinary)
r@rTr8rRrOZb2a_qpr'r`rgrH)
rrQrr=rerDrArErFr>rrr�set_bytes_content�s!

rp)rOZ
email.charsetr:Z
email.messageZemail.errorsrrZraw_data_managerr,rr.�splitrr/r=r1r@rHrTrfrir�strrnr2ZMessagerpr0�	bytearray�
memoryviewr"rrrr�<module>sD6			'					

?>