File: //usr/lib/python3/dist-packages/future/backports/email/__pycache__/generator.cpython-310.pyc
o
,�]@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 s: d|v r|d }|d= nd } || _ || _|| _|| _d S )N�policy)�_fp�
_mangle_from_�maxheaderlenr )�self�outfp�mangle_from_r �_3to2kwargsr � r �B/usr/lib/python3/dist-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�}| jdur!|j| jd�}|j| _| �| j�| _d| _| �d�| _| j }|j }z-|| _ ||_ |r[|� � }|sSdt
�t
�
� � }| �|| j � | �
|� W || _ ||_ dS || _ ||_ w )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_NL�_EMPTY�_encoded_EMTPY�get_unixfrom�time�ctimer �_write)r �msg�unixfromr! r �old_gen_policy�old_msg_policy�ufromr 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 � t � S r )r �r r r r �_new_buffer� s zGenerator._new_bufferc C s |S r r r r r r r'