View file File name : quopri.cpython-36.opt-1.pyc Content :3 \^ � @ s� d Z ddddgZdZdZdZdZyd d lmZmZ W n e k rP dZdZY nX dd � Z dd� Zddd�Zddd�Z ddd�Zddd�Zdd� Zdd� Zdd� Zedkr�e� dS ) zHConversions to/from quoted-printable transport encoding as per RFC 1521.�encode�decode�encodestring�decodestring� =�L s 0123456789ABCDEF� � )�a2b_qp�b2a_qpNc C s: | dkr|S | dkr|S | t kp8d| ko2dkn S )z�Decide whether a particular byte ordinal needs to be quoted. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. s � _� � ~)�ESCAPE)�c� quotetabs�header� r �/usr/lib64/python3.6/quopri.py�needsquoting s r c C s( t | �} ttt| d t| d f� S )zQuote a single character.� )�ordr �bytes�HEX)r r r r �quote$ s r Fc C s< t dk r,| j� }t |||d�}|j|� dS |dfdd�}d}x�| j� }|sNP g } d} |dd� dkrv|dd � }d} xL|D ]D}t|f�}t|||�r�t|�}|r�|dkr�| jd � q|| j|� q|W |dk r�||� tj | �}x:t |�tk�r||dtd � d d� |td d� }q�W |}q@W |dk �r8||| d� dS )av Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are binary file objects. The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. The 'header' flag indicates whether we are encoding spaces as _ as per RFC 1522.N)r r � c S sj | r<| dd � dkr<|j | d d� t| dd � � | � n*| dkrX|j t| �| � n|j | | � d S )N� s � .���r r )�writer )�s�output�lineEndr r r r ; s (zencode.<locals>.writer r r r s = )r! r r )r �readr �readliner r r �append�EMPTYSTRING�join�len�MAXLINESIZE) �inputr r r �data�odatar Zprevline�lineZoutline�strippedr Zthisliner r r r , s@ c C sF t d k rt | ||d�S ddlm} || �}|� }t||||� |j� S )N)r r r )�BytesIO)r �ior. r �getvalue)r r r r. �infp�outfpr r r r j s c C s t dk r*| j� }t ||d�}|j|� dS d}�x�| j� }|s@P dt|� }}|dkr�||d |� dkr�d} |d }x.|dkr�||d |� dkr�|d }qxW nd} �x.||k �r�|||d � } | dkr�|r�|d }|d }q�| tk� r�|| }|d }q�|d |k�r| �rd} P q�|d |k �rV||d |d � tk�rV|t }|d }q�|d |k �r�t||d |d � ��r�t||d |d � ��r�|tt||d |d � �f� }|d }q�|| }|d }q�W | s2|j|d � d}q2W |�r|j|� dS )z�Read 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are binary file objects. If 'header' is true, decode underscore as space (per RFC 1522).N)r r r r r s r r � � ) r r"