a �DOg�0�@s�gd�ZdZddlmZddlZddlZddlZddlm Z ddl m Z m Z dZ dZdZGd d �d ej�Zdd d�Zddd�Zdd�ZdS))�BZ2File� BZ2Compressor�BZ2Decompressor�open�compress� decompressz%Nadeem Vawda �)rN)�RLock)rr��c@s�eZdZd)dd�dd�Zdd�Zedd ��Zd d �Zd d �Zdd�Z dd�Z d*dd�Z d+dd�Z d,dd�Z dd�Zd-dd�Zd.dd�Zd d!�Zd"d#�Zejfd$d%�Zd&d'�Zd(S)/r�r� �� compresslevelcCs8t�|_d|_d|_t|_d|kr.dks8ntd��|dvrJd}t}nb|dvrfd}t}t |�|_ nF|d vr�d }t}t |�|_ n*|d vr�d }t}t |�|_ ntd |f��t |t t tjf�r�t||�|_d|_||_n*t|d�s�t|d�r�||_||_ntd��|jtk�r.tj|jttd�}t�|�|_nd|_dS)NFr r z%compresslevel must be between 1 and 9)�r �rbr)�w�wbr)�x�xbr)�a�abr�Invalid mode: %rT�read�writez6filename must be a str, bytes, file or PathLike object)�trailing_errorr)r�_lock�_fp�_closefp� _MODE_CLOSED�_mode� ValueError� _MODE_READ� _MODE_WRITEr� _compressor� isinstance�str�bytes�os�PathLike� _builtin_open�hasattr� TypeError� _compression�DecompressReaderr�OSError�io�BufferedReader�_buffer�_pos)�self�filename�moder� mode_code�raw�r8�/usr/lib64/python3.9/bz2.py�__init__&sH     �zBZ2File.__init__cCs|j��|jtkr"Wd�dSz�|jtkr:|j��n"|jtkr\|j�|j � ��d|_ Wz,|j rp|j��Wd|_d|_ t|_d|_q�d|_d|_ t|_d|_0nJz,|j r�|j��Wd|_d|_ t|_d|_nd|_d|_ t|_d|_00Wd�n1�s0YdS)NF) rrrr!r1�closer"rrr#�flushr�r3r8r8r9r;es>     � � �z BZ2File.closecCs |jtkS�N)rrr=r8r8r9�closed~szBZ2File.closedcCs|��|j��Sr>)�_check_not_closedr�filenor=r8r8r9rA�szBZ2File.filenocCs|��o|j��Sr>)�readabler1�seekabler=r8r8r9rC�szBZ2File.seekablecCs|��|jtkSr>)r@rr!r=r8r8r9rB�szBZ2File.readablecCs|��|jtkSr>)r@rr"r=r8r8r9�writable�szBZ2File.writablercCs>|j�$|��|j�|�Wd�S1s00YdSr>)r�_check_can_readr1�peek)r3�nr8r8r9rF�sz BZ2File.peek�����cCs>|j�$|��|j�|�Wd�S1s00YdSr>)rrEr1r�r3�sizer8r8r9r�sz BZ2File.readcCsL|j�2|��|dkrtj}|j�|�Wd�S1s>0YdS)Nr)rrEr/�DEFAULT_BUFFER_SIZEr1�read1rIr8r8r9rL�s z BZ2File.read1cCs>|j�$|��|j�|�Wd�S1s00YdSr>)rrEr1�readinto)r3�br8r8r9rM�szBZ2File.readintocCsbt|t�s$t|d�std��|��}|j�$|��|j�|�Wd�S1sT0YdS�N� __index__zInteger argument expected) r$�intr*r+rPrrEr1�readlinerIr8r8r9rR�s  zBZ2File.readlinecCsbt|t�s$t|d�std��|��}|j�$|��|j�|�Wd�S1sT0YdSrO) r$rQr*r+rPrrEr1� readlinesrIr8r8r9rS�s  zBZ2File.readlinescCs�|j�h|��t|ttf�r(t|�}nt|�}|j}|j� |�}|j � |�|j |7_ |Wd�S1st0YdSr>) r�_check_can_writer$r&� bytearray�len� memoryview�nbytesr#rrrr2)r3�data�length� compressedr8r8r9r�s   z BZ2File.writecCs8|j�tj�||�Wd�S1s*0YdSr>)rr,� BaseStream� writelines)r3�seqr8r8r9r]�szBZ2File.writelinescCs@|j�&|��|j�||�Wd�S1s20YdSr>)r�_check_can_seekr1�seek)r3�offset�whencer8r8r9r`sz BZ2File.seekcCsZ|j�@|��|jtkr2|j��Wd�S|jWd�S1sL0YdSr>)rr@rr!r1�tellr2r=r8r8r9rcs  z BZ2File.tellN)r )r)rH)rH)rH)rH)�__name__� __module__� __qualname__r:r;�propertyr?rArCrBrDrFrrLrMrRrSrr]r/�SEEK_SETr`rcr8r8r8r9rs$ ?     rrr cCs�d|vr d|vrPtd|f��n0|dur0td��|dur@td��|durPtd��|�dd�}t|||d�}d|vr�t�||||�S|SdS) N�trNrz0Argument 'encoding' not supported in binary modez.Argument 'errors' not supported in binary modez/Argument 'newline' not supported in binary moderr )r �replacerr/� TextIOWrapper)r4r5r�encoding�errors�newline�bz_mode� binary_filer8r8r9rs rcCst|�}|�|�|��Sr>)rrr<)rYr�compr8r8r9rGsrcCsfg}|r\t�}z|�|�}Wnty:|r4Yq\n�Yn0|�|�|jsTtd��|j}qd�|�S)NzACompressed data ended before the end-of-stream marker was reached�)rrr.�append�eofr � unused_data�join)rY�results�decomp�resr8r8r9rRs  r)rr NNN)r )�__all__� __author__�builtinsrr)r/r'r,� threadingr�_bz2rrrr!r"r\rrrr8r8r8r9�s$  � )