o
    éT•j#  ã                   @   sž   d Z ddlZddlZddlmZ ddd„Zdd	d
„ZG dd„ dejƒZG dd„ dejƒZG dd„ dej	ƒZ	G dd„ deej
ƒZ
G dd„ deejƒZdd„ ZdS )a  Python 'uu_codec' Codec - UU content transfer encoding.

This codec de/encodes from bytes to bytes.

Written by Marc-Andre Lemburg (mal@lemburg.com). Some details were
adapted from uu.py which was written by Lance Ellinghouse and
modified by Jack Jansen and Fredrik Lundh.
é    N)ÚBytesIOÚstrictú<data>é¶  c           	      C   s–   |dksJ ‚t | ƒ}t ƒ }|j}|j}| dd¡}| dd¡}|d|d@ |f  d¡ƒ |d	ƒ}|r?|t |¡ƒ |d	ƒ}|s2|d
ƒ | ¡ t| ƒfS )Nr   Ú
z\núz\rzbegin %o %s
iÿ  Úasciié-   s    
end
)	r   ÚreadÚwriteÚreplaceÚencodeÚbinasciiÚb2a_uuÚgetvalueÚlen)	ÚinputÚerrorsÚfilenameÚmodeÚinfileÚoutfiler
   r   Úchunk© r   ú)/usr/lib/python3.10/encodings/uu_codec.pyÚ	uu_encode   s   þr   c           
   
   C   sî   |dksJ ‚t | ƒ}t ƒ }|j}|j}	 |ƒ }|stdƒ‚|d d… dkr&nq	 |ƒ }|r1|dkr2n7zt |¡}W n* tjyc } z|d d	 d
@ d d d }	t |d |	… ¡}W Y d }~nd }~ww ||ƒ q(|sotdƒ‚| ¡ t| ƒfS )Nr   é   z"Missing "begin" line in input dataé   s   beginTs   end
r   é    é?   é   é   zTruncated input data)	r   Úreadliner   Ú
ValueErrorr   Úa2b_uuÚErrorr   r   )
r   r   r   r   r"   r   ÚsÚdataÚvÚnbytesr   r   r   Ú	uu_decode%   s8   û€ýõr*   c                   @   s    e Zd Zddd„Zddd„ZdS )ÚCodecr   c                 C   ó
   t ||ƒS ©N)r   ©Úselfr   r   r   r   r   r   G   ó   
zCodec.encodec                 C   r,   r-   )r*   r.   r   r   r   ÚdecodeJ   r0   zCodec.decodeN©r   )Ú__name__Ú
__module__Ú__qualname__r   r1   r   r   r   r   r+   F   s    
r+   c                   @   ó   e Zd Zddd„ZdS )ÚIncrementalEncoderFc                 C   ó   t || jƒd S ©Nr   )r   r   ©r/   r   Úfinalr   r   r   r   N   ó   zIncrementalEncoder.encodeN©F)r3   r4   r5   r   r   r   r   r   r7   M   ó    r7   c                   @   r6   )ÚIncrementalDecoderFc                 C   r8   r9   )r*   r   r:   r   r   r   r1   R   r<   zIncrementalDecoder.decodeNr=   )r3   r4   r5   r1   r   r   r   r   r?   Q   r>   r?   c                   @   ó   e Zd ZeZdS )ÚStreamWriterN©r3   r4   r5   ÚbytesÚcharbuffertyper   r   r   r   rA   U   ó    rA   c                   @   r@   )ÚStreamReaderNrB   r   r   r   r   rF   X   rE   rF   c                
   C   s   t jdttttttdd�S )NÚuuF)Únamer   r1   ÚincrementalencoderÚincrementaldecoderÚstreamreaderÚstreamwriterÚ_is_text_encoding)ÚcodecsÚ	CodecInfor   r*   r7   r?   rF   rA   r   r   r   r   Úgetregentry]   s   ørP   )r   r   r   r2   )Ú__doc__rN   r   Úior   r   r*   r+   r7   r?   rA   rF   rP   r   r   r   r   Ú<module>   s    	

!