Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib/python3.7/site-packages/future/backports/email/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/future/backports/email/__pycache__/generator.cpython-37.pyc

B

�A�[@L�@s8dZddlmZddlmZddlmZddlmZddlmZddlmZdd	d
gZ	ddl
Z
ddlZddlZddl
Z
ddlZddlmZmZdd
lmZddlmZddlmZddlmmmZdZdZe
�de
j �Z!Gdd�de"�Z#Gdd
�d
e#�Z$dZ%Gdd	�d	e#�Z&e'e(ej)d��Z*de*Z+e#j,Z,dS)z:Classes to generate plain text from a message object tree.�)�print_function)�unicode_literals)�division)�absolute_import)�super)�str�	Generator�DecodedGenerator�BytesGeneratorN)�StringIO�BytesIO)�compat32)�Header)�_has_surrogates�_�
z^From c@s�eZdZdZd(dd�Zdd�Zd)d	d
�Zdd�Zd
Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZeZdd�Zdd�Zd d!�Zd"d#�Zed*d$d%��Zed&d'��ZdS)+rz�Generates output from a Message object tree.

    This basic generator writes the message to the given file object as plain
    text.
    TNcKs8d|kr|d}|d=nd}||_||_||_||_dS)N�policy)�_fp�
_mangle_from_�maxheaderlenr)�self�outfp�mangle_from_rZ_3to2kwargsr�r�Q/opt/alt/python37/lib/python3.7/site-packages/future/backports/email/generator.py�__init__+szGenerator.__init__cCs|j�|�dS)N)r�write)r�srrrrHszGenerator.writeFcCs�|jdkr|jn|j}|dk	r*|j|d�}|jdk	rB|j|jd�}|j|_|�|j�|_d|_|�d�|_|j}|j}zL||_||_|r�|�	�}|s�dt
�t
�
��}|�||j�|�
|�Wd||_||_XdS)azPrint the message object tree rooted at msg to the output file
        specified when the Generator instance was created.

        unixfrom is a flag that forces the printing of a Unix From_ delimiter
        before the first object in the message tree.  If the original message
        has no From_ delimiter, a `standard' one is crafted.  By default, this
        is False to inhibit the printing of any From_ delimiter.

        Note that for subobjects, no From_ line is printed.

        linesep specifies the characters used to indicate a new line in
        the output.  The default value is determined by the policy.

        N)�linesep)�max_line_length�zFrom nobody )r�clonerr�_NL�_encode�_encoded_NLZ_EMPTYZ_encoded_EMTPY�get_unixfrom�time�ctimer�_write)r�msg�unixfromrrZold_gen_policyZold_msg_policyZufromrrr�flattenLs,
zGenerator.flattencCs|j||jd|jd�S)z1Clone this generator with the exact same options.N)r)�	__class__rr)r�fprrrr!{szGenerator.cloner cCst�S)N)r)rrrr�_new_buffer�szGenerator._new_buffercCs|S)Nr)rrrrrr#�szGenerator._encodecCs�|sdS|�d�}x0|dd�D] }|�|�d��|�|j�q W|d�d�}|�|�t|d�t|�kr||�|j�dS)NT���z
)�
splitlinesr�rstripr"�len)r�lines�lineZlaststrippedrrr�_write_lines�s

zGenerator._write_linescCsh|j}z|��|_}|�|�Wd||_Xt|dd�}|dkrL|�|�n||�|j�|���dS)N�_write_headers)rr.�	_dispatch�getattrr6r�getvalue)rr)ZoldfpZsfp�methrrrr(�szGenerator._writecCst|��}|��}t�||f��dd�}t|d|d�}|dkrh|�dd�}t|d|d�}|dkrh|j}||�dS)N�-rZ_handle_)�get_content_maintype�get_content_subtype�
UNDERSCORE�join�replacer8�
_writeBody)rr)�main�subZspecificr:Zgenericrrrr7�szGenerator._dispatchcCs:x(|��D]\}}|�|j�||��q
W|�|j�dS)N)�	raw_itemsrr�foldr")rr)�h�vrrrr6�szGenerator._write_headerscCs�|��}|dkrdSt|t�s.tdt|���t|j�rd|�d�}|dk	rd|d=|�||�|��}|j	rvt
�d|�}|�|�dS)Nzstring payload expected: %s�charsetzcontent-transfer-encodingz>From )
�get_payload�
isinstancer�	TypeError�typer�_payload�	get_param�set_payloadr�fcrerCr5)rr)�payloadrHrrr�_handle_text�s


zGenerator._handle_textcCs�g}|��}|dkrg}n(t|t�r2|�|�dSt|t�sB|g}x>|D]6}|��}|�|�}|j|d|jd�|�	|�
��qHW|��}|s�|j�
|�}|�|�}|�|�|jdk	r�|jr�t�d|j�}	n|j}	|�|	�|�|j�|�d||j�|�r|j�|�d��x4|D],}
|�|jd||j�|j�|
��qW|�|jd|d�|jdk	�r�|�|j�|j�r�t�d|j�}n|j}|�|�dS)NF)r*rz>From z--r)rIrJrr�listr.r!r+r"�appendr9�get_boundaryr$r?�_make_boundary�set_boundary�preamblerrPrCr5r�pop�epilogue)rr)Zmsgtexts�subparts�partr�g�boundaryZalltextrXZ	body_partrZrrr�_handle_multipart�sL









zGenerator._handle_multipartcCs0|j}|jdd�|_z|�|�Wd||_XdS)Nr)r)rr!r_)rr)�prrr�_handle_multipart_signed/s
z"Generator._handle_multipart_signedcCs�g}x�|��D]t}|��}|�|�}|j|d|jd�|��}|�|j�}|rx|d|jkrx|�	|j�
|dd���q|�	|�qW|j�|j�
|��dS)NF)r*rr/)
rIr.r!r+r"r9�splitr$�_encoded_EMPTYrTr?rr)rr)Zblocksr\rr]�textr3rrr�_handle_message_delivery_status:s
z)Generator._handle_message_delivery_statuscCs^|��}|�|�}|j}t|t�rD|j|�d�d|jd�|��}n
|�	|�}|j
�|�dS)NrF)r*r)r.r!rMrJrSr+rIr"r9r#rr)rr)rr]rQrrr�_handle_messageOs




zGenerator._handle_messagecCszt�tj�}dt|d}|dkr(|S|}d}xD|�dt�|�dtj�}|�	|�sZP|dt
|�}|d7}q2W|S)Nz===============z==rz^--z(--)?$�.�)�random�	randrange�sys�maxsize�_fmt�_compile_re�re�escape�	MULTILINE�searchr)�clsrd�tokenr^�b�counterZcrerrrrVhs
zGenerator._make_boundarycCst�||�S)N)ro�compile)rsr�flagsrrrrnzszGenerator._compile_re)TN)FN)N)�__name__�
__module__�__qualname__�__doc__rrr+r!rcr.r#r5r(r7r6rRrAr_rarerf�classmethodrVrnrrrrr!s*

/

;csTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Z�fdd�Z	e	Z
ed
d��Z�Z
S)r
a�Generates a bytes version of a Message object tree.

    Functionally identical to the base Generator except that the output is
    bytes and not string.  When surrogates were used in the input to encode
    bytes, these are decoded back to bytes for output.  If the policy has
    cte_type set to 7bit, then the message is transformed such that the
    non-ASCII bytes are properly content transfer encoded, using the charset
    unknown-8bit.

    The outfp object must accept bytes in its write method.
    �cCs|j�t|��dd��dS)N�ascii�surrogateescape)rrr�encode)rrrrrr�szBytesGenerator.writecCst�S)N)r)rrrrr.�szBytesGenerator._new_buffercCs
|�d�S)Nr)r�)rrrrrr#�szBytesGenerator._encodecCs<x*|��D]\}}|j�|j�||��q
W|�|j�dS)N)rDrrr�fold_binaryr")rr)rFrGrrrr6�szBytesGenerator._write_headerscs\|jdkrdSt|j�rH|jjdksH|jr:t�d|j�|_|�|j�ntt	|��
|�dS)N�7bitz>From )rMrr�cte_typerrPrCr5rr
rR)rr))r,rrrR�s
zBytesGenerator._handle_textcCst�|�d�|�S)Nr)rorwr�)rsrrxrrrrn�szBytesGenerator._compile_re)ryrzr{r|rcrr.r#r6rRrAr}rn�
__classcell__rr)r,rr
~s
zD[Non-text (%(type)s) part of message omitted, filename %(filename)s]c@s"eZdZdZd	dd�Zdd�ZdS)
r	z�Generates a text representation of a message.

    Like the Generator base class, except that non-text parts are substituted
    with a format string representing the part.
    T�NNcCs*t�||||�|dkr t|_n||_dS)a�Like Generator.__init__() except that an additional optional
        argument is allowed.

        Walks through all subparts of a message.  If the subpart is of main
        type `text', then it prints the decoded payload of the subpart.

        Otherwise, fmt is a format string that is used instead of the message
        payload.  fmt is expanded with the following keywords (in
        %(keyword)s format):

        type       : Full MIME type of the non-text part
        maintype   : Main MIME type of the non-text part
        subtype    : Sub-MIME type of the non-text part
        filename   : Filename of the non-text part
        description: Description associated with the non-text part
        encoding   : Content transfer encoding of the non-text part

        The default value for fmt is None, meaning

        [Non-text (%(type)s) part of message omitted, filename %(filename)s]
        N)rr�_FMTrm)rrrr�fmtrrrr�szDecodedGenerator.__init__cCs�x�|��D]v}|��}|dkr4t|jdd�|d�q
|dkr>q
t|j|��|��|��|�d�|�dd�|�d	d
�d�|d�q
WdS)NrdF)�decode)�file�	multipartz
[no filename]zContent-Descriptionz[no description]zContent-Transfer-Encodingz
[no encoding])rL�maintype�subtype�filename�description�encoding)	�walkr<�printrIrm�get_content_typer=�get_filename�get)rr)r\r�rrrr7�s 
zDecodedGenerator._dispatch)Tr�N)ryrzr{r|rr7rrrrr	�s
rhz%%0%dd)-r|�
__future__rrrrZfuture.builtinsrr�__all__rorkr&ri�warnings�iorrZ"future.backports.email._policybaser
Zfuture.backports.email.headerrZfuture.backports.email.utilsrZfuture.backports.email.charsetZ	backports�emailrH�_charsetr>�NLrwrqrP�objectrr
r�r	r2�reprrl�_widthrmrVrrrr�<module>s:
_68

Hacked By AnonymousFox1.0, Coded By AnonymousFox