Your IP : 3.144.255.247


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/quopri.cpython-34.pyc

�
i fa�@sdZddddgZdZdZdZdZyd	d
lmZmZWne	k
rjdZdZYnXdd
�Z
dd�Zddd�Zdddd�Z
ddd�Zddd�Zdd�Zdd�Zdd�Zedkr�e�ndS)zHConversions to/from quoted-printable transport encoding as per RFC 1521.�encode�decode�encodestring�decodestring�=�Ls0123456789ABCDEF��)�a2b_qp�b2a_qpNcCs\t|t�st�|dkr%|S|dkr5|S|tkp[d|koXdkn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 	�_� �~)�
isinstance�bytes�AssertionError�ESCAPE)�c�	quotetabs�header�r�+/opt/alt/python34/lib64/python3.4/quopri.py�needsquotingsrcCsWt|t�r!t|�dks't�t|�}ttt|dt|df�S)zQuote a single character.��)rr�lenr�ordr�HEX)rrrr�quote$s'rFc
Cs�tdk	rA|j�}t|d|d|�}|j|�dS|ddd�}d}x>|j�}|srPng}	d}
|d
d�dkr�|dd�}d}
nxm|D]e}t|f�}t|||�r�t|�}n|r|d	kr|	jd
�q�|	j|�q�W|dk	r6||�ntj	|	�}xHt
|�tkr�||dtd�dd�|tdd�}qHW|}q\W|dk	r�||d|
�ndS)avRead '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.Nrrs
cSs�|rN|dd�dkrN|j|dd�t|dd��|�n7|dkrt|jt|�|�n|j||�dS)Nrs 	�.���rr)�writer)�s�output�lineEndrrrr ;s
2zencode.<locals>.writerrrrr#s=
rr)r
�readr �readlinerrr�append�EMPTYSTRING�joinr�MAXLINESIZE)
�inputr"rr�data�odatar Zprevline�lineZoutlineZstrippedrZthislinerrrr,s@	

	


cCsdtdk	r"t|d|d|�Sddlm}||�}|�}t||||�|j�S)Nrrr)�BytesIO)r
�ior.r�getvalue)r!rrr.�infp�outfprrrrjs	cCs�tdk	r;|j�}t|d|�}|j|�dSd}x4|j�}|sZPndt|�}}|dkr�||d|�dkr�d}	|d}x=|dkr�||d|�dkr�|d}q�Wnd}	xn||krS|||d�}
|
dkr/|r/|d	}|d}q�|
tkrR||
}|d}q�|d|krs|	rsd}	Pq�|d|kr�||d|d
�tkr�|t}|d
}q�|d
|kr<t||d|d
��r<t||d
|d��r<|tt||d|d��f�}|d}q�||
}|d}q�W|	sD|j|d�d}qDqDW|r�|j|�ndS)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).Nrrrrs
s 	
rr��)	r	r$r r%rr�ishexr�unhex)r*r"rr+r,�newr-�i�n�partialrrrrrusR
&
)



.

L+


cCs^tdk	rt|d|�Sddlm}||�}|�}t||d|�|j�S)Nrr)r.)r	r/r.rr0)r!rr.r1r2rrrr�s	cCset|t�st�d|ko,dknpdd|koHdknpdd|kobdkSS)zDReturn true if the byte ordinal 'c' is a hexadecimal digit in ASCII.�0�9�a�f�A�F)rrr)rrrrr5�sr5cCs�d}x�|D]�}t|f�}d|ko9dknrMtd�}nzd|koddknr|td�d}nKd	|ko�d
knr�td	�d}nds�tdt|���|d
t|�|}q
W|S)z.Get the integer value of a hexadecimal number.rr;r<�0r=r>�a�
r?r@Fznon-hex digit r)rrr�repr)r!�bitsrr8rrrr6�s
r6c(Cs;ddl}ddl}y)|j|jdd�d�\}}Wni|jk
r�}zF|j|_t|�td�td�td�|jd�WYdd}~XnXd}d}x>|D]6\}}|dkr�d}n|d	kr�d}q�q�W|r,|r,|j|_td
�|jd�n|s>dg}nd}	x�|D]�}
|
dkrl|jj	}n^yt
|
d�}WnHtk
r�}z(|jjd
|
|f�d}	wKWYdd}~XnXz6|r�t
||jj	�nt||jj	|�Wd|
dkr|j�nXqKW|	r7|j|	�ndS)NrrZtdz"usage: quopri [-t | -d] [file] ...z-t: quote tabsz-d: decode; default encoder3z-tz-dz -t and -d are mutually exclusive�-�rbz%s: can't open (%s)
)�sys�getopt�argv�error�stderr�stdout�print�exit�stdin�buffer�open�OSErrorr rr�close)rHrIZopts�args�msgZdecoZtabs�orB�sts�file�fprrr�main�sT)



 	


r[�__main__)�__doc__�__all__rr)rr'Zbinasciir	r
�ImportErrorrrrrrrr5r6r[�__name__rrrr�<module>s*
>+.

?>