3 \� �@s�dZddlZddlZddlmZddd�Zdd d �ZGd d �d ej�ZGd d�dej�ZGdd�dej �Z Gdd�deej �Z Gdd�deej �Z dd�Z dS)aPython 'uu_codec' Codec - UU content transfer encoding. This codec de/encodes from bytes to bytes. Written by Marc-Andre Lemburg ([email protected]). Some details were adapted from uu.py which was written by Lance Ellinghouse and modified by Jack Jansen and Fredrik Lundh. �N)�BytesIO�strict��c Cstt|�}t�}|j}|j}|d|d@|fjd��|d�}x|rZ|tj|��|d�}q>W|d�|j�t|�fS)Nz begin %o %s i��ascii�-s end )r�read�write�encode�binasciiZb2a_uu�getvalue�len) �input�errors�filename�mode�infile�outfilerr �chunk�r�*/usr/lib64/python3.6/encodings/uu_codec.py� uu_encodes rc Cs�t|�}t�}|j}|j}x(|�}|s.td��|dd�dkrPqWx�|�}| sZ|dkr\Pytj|�}WnRtjk r�}z4|ddd@ddd } tj|d| ��}WYdd}~XnX||�qFW|s�td ��|j�t|�fS) Nz"Missing "begin" line in input data�sbeginsend r� �?��zTruncated input data) r�readliner � ValueErrorr Za2b_uu�Errorr r ) rrrrrr �s�data�v�nbytesrrr� uu_decode!s.$ r$c@s eZdZddd�Zddd�ZdS) �CodecrcCs t||�S)N)r)�selfrrrrrr Csz Codec.encodecCs t||�S)N)r$)r&rrrrr�decodeFsz Codec.decodeN)r)r)�__name__� __module__� __qualname__r r'rrrrr%Bs r%c@seZdZddd�ZdS)�IncrementalEncoderFcCst||j�dS)Nr)rr)r&r�finalrrrr JszIncrementalEncoder.encodeN)F)r(r)r*r rrrrr+Isr+c@seZdZddd�ZdS)�IncrementalDecoderFcCst||j�dS)Nr)r$r)r&rr,rrrr'NszIncrementalDecoder.decodeN)F)r(r)r*r'rrrrr-Msr-c@seZdZeZdS)� StreamWriterN)r(r)r*�bytes�charbuffertyperrrrr.Qsr.c@seZdZeZdS)� StreamReaderN)r(r)r*r/r0rrrrr1Tsr1c Cstjdttttttdd�S)N�uuF)�namer r'�incrementalencoder�incrementaldecoder� streamreader� streamwriter�_is_text_encoding)�codecs� CodecInforr$r+r-r1r.rrrr� getregentryYsr;)rrr)r) �__doc__r9r �iorrr$r%r+r-r.r1r;rrrr�s   !