Your IP : 3.138.134.247


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

U

i�f�Q�@s�dddgZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
d	Zd
Ze�d�Ze�dej�Ze�d
�ZGdd�d�ZGdd�de�ZdZGdd�de�Zeeejd��ZdeZejZdS)�	Generator�DecodedGenerator�BytesGenerator�N)�deepcopy)�StringIO�BytesIO)�_has_surrogates)�HeaderWriteError�_�
z
\r\n|\r|\nz^From z\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]c@s�eZdZd&dd�dd�Zdd�Zd'dd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
e
Zdd�Zdd�Zdd�Zd d!�Zed(d"d#��Zed$d%��ZdS))rN��policycCs6|dkr|dkrdn|j}||_||_||_||_dS)NT)�mangle_from_�_fp�
_mangle_from_�maxheaderlenr
)�self�outfprrr
�r�4/opt/alt/python38/lib64/python3.8/email/generator.py�__init__&szGenerator.__init__cCs|j�|�dS�N)r�write�r�srrrrFszGenerator.writeFcCs�|jdkr|jn|j}|dk	r*|j|d�}|jdk	rB|j|jd�}|j|_|�|j�|_d|_|�|j�|_|j}|j}zL||_||_|r�|�	�}|s�dt
�t
�
��}|�||j�|�
|�W5||_||_XdS)N)�linesep�Zmax_line_length�zFrom nobody )r
�clonerr�_NL�_encode�_encoded_NLZ_EMPTY�_encoded_EMPTYZget_unixfrom�time�ctimer�_write)r�msg�unixfromrr
Zold_gen_policyZold_msg_policyZufromrrr�flattenJs,
zGenerator.flattencCs|j||jd|jd�S�Nr)�	__class__rr
)r�fprrrr{s
�zGenerator.clonecCst�Sr)r�rrrr�_new_buffer�szGenerator._new_buffercCs|Srrrrrrr �szGenerator._encodecCsT|sdSt�|�}|dd�D]}|�|�|�|j�q|drP|�|d�dS)N���)�NLCRE�splitrr)r�lines�linerrr�_write_lines�s

zGenerator._write_linescCs�|j}z"d|_|��|_}|�|�W5||_|j}|`X|r�t|�}|�d�dkrd|d|d<n|�d|d�|�d|d�t|dd�}|dkr�|�|�n||�|j�	|�
��dS)N�content-transfer-encodingr�Content-Transfer-Encoding�content-type��_write_headers)r�
_munge_cter-�	_dispatchr�getZreplace_header�getattrr8r�getvalue)rr&ZoldfpZ	munge_cteZsfp�methrrrr%�s&zGenerator._writecCst|��}|��}t�||f��dd�}t|d|d�}|dkrh|�dd�}t|d|d�}|dkrh|j}||�dS)N�-r
Z_handle_)�get_content_maintype�get_content_subtype�
UNDERSCORE�join�replacer<�
_writeBody)rr&�main�subZspecificr>Zgenericrrrr:�szGenerator._dispatchcCs�|��D]�\}}|j�||�}|jjr�|jj}|�|jj�sPtd|�d|����|}|�|�rp|dt|��}t�	|�r�td|����|�
|�q|�
|j�dS)Nz folded header does not end with z: z folded header contains newline: )�	raw_itemsr
ZfoldZverify_generated_headersr�endswithr	�len�NEWLINE_WITHOUT_FWSP�searchrr)rr&�h�vZfoldedrZfolded_no_lineseprrrr8�s"�

�zGenerator._write_headerscCs�|��}|dkrdSt|t�s.tdt|���t|j�r~|�d�}|dk	r~t|�}|d=|�	||�|��}|d|df|_
|jr�t�
d|�}|�|�dS)Nzstring payload expected: %s�charsetr4r6�>From )�get_payload�
isinstance�str�	TypeError�typer�_payloadZ	get_paramrZset_payloadr9r�fcrerGr3)rr&�payloadrOrrr�_handle_text�s$


�zGenerator._handle_textcCs�g}|��}|dkrg}n(t|t�r2|�|�dSt|t�sB|g}|D]6}|��}|�|�}|j|d|jd�|�	|�
��qF|��}|s�|j�
|�}|�|�}|�|�|jdk	r�|jr�t�d|j�}	n|j}	|�|	�|�|j�|�d||j�|�r|j�|�d��|D],}
|�|jd||j�|j�|
��q|�|jd|d|j�|jdk	�r�|j�r�t�d|j�}n|j}|�|�dS)NF�r'rrPz--r)rQrRrSr�listr-rr(r�appendr=Zget_boundaryr!rC�_make_boundaryZset_boundary�preamblerrWrGr3r�pop�epilogue)rr&ZmsgtextsZsubparts�partr�g�boundaryZalltextr^Z	body_partr`rrr�_handle_multipartsJ







zGenerator._handle_multipartcCs0|j}|jdd�|_z|�|�W5||_XdS)Nrr)r
rrd)rr&�prrr�_handle_multipart_signedJs
z"Generator._handle_multipart_signedcCs�g}|��D]t}|��}|�|�}|j|d|jd�|��}|�|j�}|rv|d|jkrv|�	|j�
|dd���q|�	|�q|j�|j�
|��dS)NFrZr.)
rQr-rr(rr=r0r!r"r\rCrr)rr&Zblocksrarrb�textr1rrr�_handle_message_delivery_statusUs
z)Generator._handle_message_delivery_statuscCs^|��}|�|�}|j}t|t�rD|j|�d�d|jd�|��}n
|�	|�}|j
�|�dS)NrFrZ)r-rrVrRr[r(rQrr=r rr)rr&rrbrXrrr�_handle_messagejs




zGenerator._handle_messagecCsvt�tj�}dt|d}|dkr(|S|}d}|�dt�|�dtj�}|�	|�sXqr|dt
|�}|d7}q0|S)Nz===============z==rz^--z(--)?$�.r7)�randomZ	randrange�sys�maxsize�_fmt�_compile_re�re�escape�	MULTILINErLrS)�clsrg�tokenrc�bZcounterZcrerrrr]�s

zGenerator._make_boundarycCst�||�Sr)rp�compile�rsr�flagsrrrro�szGenerator._compile_re)NN)FN)N)�__name__�
__module__�__qualname__rrr(rr-r r3r%r:r8rYrErdrfrhri�classmethodr]rorrrrrs,
� 
1':csLeZdZdd�Zdd�Zdd�Zdd�Z�fd	d
�ZeZe	dd��Z
�ZS)
rcCs|j�|�dd��dS)N�ascii�surrogateescape)rr�encoderrrrr�szBytesGenerator.writecCst�Sr)rr,rrrr-�szBytesGenerator._new_buffercCs
|�d�S�Nr})rrrrrr �szBytesGenerator._encodecCs8|��D]\}}|j�|j�||��q|�|j�dSr)rHrrr
Zfold_binaryr)rr&rMrNrrrr8�szBytesGenerator._write_headerscs\|jdkrdSt|j�rH|jjdksH|jr:t�d|j�|_|�|j�ntt	|��
|�dS)NZ7bitrP)rVrr
Zcte_typerrWrGr3�superrrY)rr&�r*rrrY�s
zBytesGenerator._handle_textcCst�|�d�|�Sr�)rprvrrwrrrro�szBytesGenerator._compile_re)ryrzr{rr-r r8rYrEr|ro�
__classcell__rrr�rr�s

zD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s$eZdZddd�dd�Zdd�ZdS)rNrcCs.tj|||||d�|dkr$t|_n||_dSr))rr�_FMTrn)rrrrZfmtr
rrrr�s�zDecodedGenerator.__init__cCs�|��D]v}|��}|dkr2t|jdd�|d�q|dkr<qt|j|��|��|��|�d�|�dd�|�d	d
�d�|d�qdS)NrgF)�decode)�fileZ	multipartz
[no filename]zContent-Descriptionz[no description]r5z
[no encoding])rU�maintypeZsubtype�filenameZdescription�encoding)	�walkr@�printrQrnZget_content_typerA�get_filenamer;)rr&rar�rrrr:�s(���	�zDecodedGenerator._dispatch)NNN)ryrzr{rr:rrrrr�s�r7z%%0%dd)�__all__rprlr#rk�copyr�iorrZemail.utilsrZemail.errorsr	rB�NLrvr/rrrWrKrrr�rrJ�reprrmZ_widthrnr]rrrr�<module>s.


3;

?>