
    Rh#                        d Z ddlZddlZddlmZ ddZddZ G d dej                        Z G d d	ej                        Z G d
 dej                        Z	 G d deej                        Z
 G d deej                        Zd Zy)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)BytesIOc                    |dk(  sJ t        |       }t               }|j                  }|j                  }|j                  dd      }|j                  dd      } |d|dz  |fz  j	                  d              |d	      }|r& |t        j                  |              |d	      }|r& |d
       |j                         t        |       fS )Nstrict
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   chunks	            )/usr/lib/python3.12/encodings/uu_codec.py	uu_encoder      s    XU^FiG;;DMME U+HU+H 
?dUlH55
=
=g
FGHE
hooe$%R  
+E
++    c                    |dk(  sJ t        |       }t               }|j                  }|j                  }	  |       }|st        d      |d d dk(  rn	  |       }|r|dk(  rn	 t	        j
                  |      } ||       .|st        d      |j                         t        |       fS # t        j                  $ r6}|d   dz
  dz  d	z  dz   d
z  }	t	        j
                  |d |	       }Y d }~ud }~ww xY w)Nr   z"Missing "begin" line in input data   s   begins   end
r       ?         zTruncated input data)	r   readliner   
ValueErrorr   a2b_uuErrorr   r   )
r   r   r   r   r"   r   sdatavnbytess
             r   	uu_decoder*   %   s   XU^FiGHMME JABBRa5H  JAM	/??1%D 	d  /00E
++ ~~ 	/!R2~*Q.14F??1Wf:.D	/s   %B+ +C4>,C//C4c                       e Zd ZddZddZy)Codecc                     t        ||      S N)r   selfr   r   s      r   r   zCodec.encodeG       ''r   c                     t        ||      S r.   )r*   r/   s      r   decodezCodec.decodeJ   r1   r   Nr   )__name__
__module____qualname__r   r3    r   r   r,   r,   F   s    ((r   r,   c                       e Zd ZddZy)IncrementalEncoderc                 4    t        || j                        d   S Nr   )r   r   r0   r   finals      r   r   zIncrementalEncoder.encodeN       ,Q//r   NF)r5   r6   r7   r   r8   r   r   r:   r:   M       0r   r:   c                       e Zd ZddZy)IncrementalDecoderc                 4    t        || j                        d   S r<   )r*   r   r=   s      r   r3   zIncrementalDecoder.decodeR   r?   r   Nr@   )r5   r6   r7   r3   r8   r   r   rC   rC   Q   rA   r   rC   c                       e Zd ZeZy)StreamWriterNr5   r6   r7   bytescharbuffertyper8   r   r   rF   rF   U       Nr   rF   c                       e Zd ZeZy)StreamReaderNrG   r8   r   r   rL   rL   X   rJ   r   rL   c            
      l    t        j                  dt        t        t        t
        t        t        d      S )NuuF)namer   r3   incrementalencoderincrementaldecoderstreamreaderstreamwriter_is_text_encoding)codecs	CodecInfor   r*   r:   rC   rL   rF   r8   r   r   getregentryrW   ]   s-    --!!	 	r   )r   z<data>i  r4   )__doc__rU   r   ior   r   r*   r,   r:   rC   rF   rL   rW   r8   r   r   <module>rZ      s      ,*,B(FLL (022 0022 05&-- 5&-- 

r   