o
    éT•jÉ  ã                   @   s’   d Z ddlZddl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 'bz2_codec' Codec - bz2 compression encoding.

This codec de/encodes from bytes to bytes and is therefore usable with
bytes.transform() and bytes.untransform().

Adapted by Raymond Hettinger from zlib_codec.py which was written
by Marc-Andre Lemburg (mal@lemburg.com).
é    NÚstrictc                 C   ó   |dksJ ‚t  | ¡t| ƒfS ©Nr   )Úbz2ÚcompressÚlen©ÚinputÚerrors© r   ú*/usr/lib/python3.10/encodings/bz2_codec.pyÚ
bz2_encode   ó   r   c                 C   r   r   )r   Ú
decompressr   r   r   r   r   Ú
bz2_decode   r   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   Úencode   ó   
zCodec.encodec                 C   r   r   )r   r   r   r   r   Údecode   r   zCodec.decodeN©r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r      s    
r   c                   @   ó(   e Zd Zd
dd„Zddd„Zdd„ Zd	S )ÚIncrementalEncoderr   c                 C   ó    |dksJ ‚|| _ t ¡ | _d S r   )r
   r   ÚBZ2CompressorÚcompressobj©r   r
   r   r   r   Ú__init__   ó   zIncrementalEncoder.__init__Fc                 C   s*   |r| j  |¡}|| j  ¡  S | j  |¡S r   )r!   r   Úflush)r   r	   ÚfinalÚcr   r   r   r   #   s   zIncrementalEncoder.encodec                 C   ó   t  ¡ | _d S r   )r   r    r!   ©r   r   r   r   Úreset*   ó   zIncrementalEncoder.resetNr   ©F)r   r   r   r#   r   r*   r   r   r   r   r      s    

r   c                   @   r   )ÚIncrementalDecoderr   c                 C   r   r   )r
   r   ÚBZ2DecompressorÚdecompressobjr"   r   r   r   r#   .   r$   zIncrementalDecoder.__init__Fc                 C   s$   z| j  |¡W S  ty   Y dS w )NÚ )r/   r   ÚEOFError)r   r	   r&   r   r   r   r   3   s
   ÿzIncrementalDecoder.decodec                 C   r(   r   )r   r.   r/   r)   r   r   r   r*   9   r+   zIncrementalDecoder.resetNr   r,   )r   r   r   r#   r   r*   r   r   r   r   r-   -   s    

r-   c                   @   ó   e Zd ZeZdS )ÚStreamWriterN©r   r   r   ÚbytesÚcharbuffertyper   r   r   r   r3   <   ó    r3   c                   @   r2   )ÚStreamReaderNr4   r   r   r   r   r8   ?   r7   r8   c                
   C   s   t jdttttttdd�S )Nr   F)Únamer   r   ÚincrementalencoderÚincrementaldecoderÚstreamwriterÚstreamreaderÚ_is_text_encoding)ÚcodecsÚ	CodecInfor   r   r   r-   r3   r8   r   r   r   r   ÚgetregentryD   s   ørA   r   )Ú__doc__r?   r   r   r   r   r   r-   r3   r8   rA   r   r   r   r   Ú<module>   s    	

