File: //usr/local/lib/python3.9/site-packages/future/backports/email/__pycache__/generator.cpython-39.pyc
a
��?h@L � @ s6 d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ g d�Z dd l
Z
dd lZdd lZdd l
Z
dd lZdd
lmZmZ ddlmZ ddlmZ dd
lmZ dd lm m mZ dZdZe
�de
j �Z!G dd� de"�Z#G dd� de#�Z$dZ%G dd� de#�Z&e'e(ej)d ��Z*de* Z+e#j,Z,d S )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� e Zd ZdZd(dd�Zdd� Zd)d d
�Zdd� Zd
Zdd� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� ZeZdd� Zdd� Zd d!� Zd"d#� Zed*d$d%��Zed&d'� �ZdS )+r z�Generates output from a Message object tree.
This basic generator writes the message to the given file object as plain
text.
TNc K s8 d|v r|d }|d= nd }|| _ || _|| _|| _d S )N�policy)�_fp�
_mangle_from_�maxheaderlenr )�self�outfp�mangle_from_r Z_3to2kwargsr � r �J/usr/local/lib/python3.9/site-packages/future/backports/email/generator.py�__init__+ s zGenerator.__init__c C s | j �|� d S �N)r �write�r �sr r r r H s zGenerator.writeFc C s� | j du r|j n| j }|dur*|j|d�}| jdurB|j| jd�}|j| _| �| j�| _d| _| �d�| _| j }|j }zX|| _ ||_ |r�|� � }|s�dt
�t
�
� � }| �|| j � | �
|� W || _ ||_ n|| _ ||_ 0 dS )az Print 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� zFrom nobody )r �cloner r �_NL�_encode�_encoded_NLZ_EMPTYZ_encoded_EMTPY�get_unixfrom�time�ctimer �_write)r �msg�unixfromr r Zold_gen_policyZold_msg_policyZufromr r r �flattenL s0
�zGenerator.flattenc C s | j || jd| jd�S )z1Clone this generator with the exact same options.N)r )� __class__r r )r �fpr r r r$ { s
�zGenerator.cloner# c C s t � S r )r �r r r r �_new_buffer� s zGenerator._new_bufferc C s |S r r r r r r r&