a
    |Œ@hÉ  ã                   @   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   s   |dksJ ‚t  | ¡t| ƒfS ©Nr   )Úbz2ÚcompressÚlen©ÚinputÚerrors© r
   ú$lib/python3.9/encodings/bz2_codec.pyÚ
bz2_encode   s    r   c                 C   s   |dksJ ‚t  | ¡t| ƒfS r   )r   Ú
decompressr   r   r
   r
   r   Ú
bz2_decode   s    r   c                   @   s    e Zd Zddd„Zddd„ZdS )	ÚCodecr   c                 C   s
   t ||ƒS ©N)r   ©Úselfr   r	   r
   r
   r   Úencode   s    zCodec.encodec                 C   s
   t ||ƒS r   )r   r   r
   r
   r   Údecode   s    zCodec.decodeN)r   )r   )Ú__name__Ú
__module__Ú__qualname__r   r   r
   r
   r
   r   r      s   
r   c                   @   s(   e Zd Zd
dd„Zddd„Zdd„ Zd	S )ÚIncrementalEncoderr   c                 C   s    |dksJ ‚|| _ t ¡ | _d S r   )r	   r   ÚBZ2CompressorÚcompressobj©r   r	   r
   r
   r   Ú__init__   s    zIncrementalEncoder.__init__Fc                 C   s.   |r| j  |¡}|| j  ¡  S | j  |¡S d S r   )r   r   Úflush)r   r   ÚfinalÚcr
   r
   r   r   #   s    zIncrementalEncoder.encodec                 C   s   t  ¡ | _d S r   )r   r   r   ©r   r
   r
   r   Úreset*   s    zIncrementalEncoder.resetN)r   )F)r   r   r   r   r   r!   r
   r
   r
   r   r      s   

r   c                   @   s(   e Zd Zd
dd„Zddd„Zdd„ Zd	S )ÚIncrementalDecoderr   c                 C   s    |dksJ ‚|| _ t ¡ | _d S r   )r	   r   ÚBZ2DecompressorÚdecompressobjr   r
   r
   r   r   .   s    zIncrementalDecoder.__init__Fc                 C   s(   z| j  |¡W S  ty"   Y dS 0 d S )NÚ )r$   r   ÚEOFError)r   r   r   r
   r
   r   r   3   s    zIncrementalDecoder.decodec                 C   s   t  ¡ | _d S r   )r   r#   r$   r    r
   r
   r   r!   9   s    zIncrementalDecoder.resetN)r   )F)r   r   r   r   r   r!   r
   r
   r
   r   r"   -   s   

r"   c                   @   s   e Zd ZeZdS )ÚStreamWriterN©r   r   r   ÚbytesÚcharbuffertyper
   r
   r
   r   r'   <   s   r'   c                   @   s   e Zd ZeZdS )ÚStreamReaderNr(   r
   r
   r
   r   r+   ?   s   r+   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"   r'   r+   r
   r
   r
   r   ÚgetregentryD   s    ør4   )r   )r   )Ú__doc__r2   r   r   r   r   r   r"   r'   r+   r4   r
   r
   r
   r   Ú<module>   s   	

