
    daf1                         	 d dl Z d dlZe j                  Z G d de j                        Z G d de j                        Zy)    Nc                   &    e Zd Z	 d Zd Zd Zd Zy)
BaseStreamc                 2    | j                   rt        d      y )NzI/O operation on closed file)closed
ValueErrorselfs    '/root/Python-3.12.4/Lib/_compression.py_check_not_closedzBaseStream._check_not_closed   s    ;;;<<     c                 N    | j                         st        j                  d      y )NzFile not open for reading)readableioUnsupportedOperationr   s    r
   _check_can_readzBaseStream._check_can_read   "    }}))*EFF r   c                 N    | j                         st        j                  d      y )NzFile not open for writing)writabler   r   r   s    r
   _check_can_writezBaseStream._check_can_write   r   r   c                     | j                         st        j                  d      | j                         st        j                  d      y )Nz3Seeking is only supported on files open for readingz3The underlying file object does not support seeking)r   r   r   seekabler   s    r
   _check_can_seekzBaseStream._check_can_seek   sO    }})) +F G G}})) +E F F r   N)__name__
__module____qualname__r   r   r   r    r   r
   r   r   	   s    )=GGFr   r   c                   r     e Zd Z	 d ZddZ fdZd Zd ZddZd Z	d Z
ej                  fd	Zd
 Z xZS )DecompressReaderc                      y)NTr   r   s    r
   r   zDecompressReader.readable$   s    r   c                     || _         d| _        d| _        d| _        || _        || _         | j                  di | j
                  | _        || _        y )NFr   r   )_fp_eof_pos_size_decomp_factory_decomp_args_decompressor_trailing_error)r	   fpdecomp_factorytrailing_errordecomp_argss        r
   __init__zDecompressReader.__init__'   sZ    		 
  .'1T11FD4E4EF  .r   c                 .    d | _         t        | 	         S N)r(   superclose)r	   	__class__s    r
   r2   zDecompressReader.close;   s    !w}r   c                 6    | j                   j                         S r0   )r"   r   r   s    r
   r   zDecompressReader.seekable?   s    xx  ""r   c                    t        |      5 }|j                  d      5 }| j                  t        |            }||d t        |       d d d        d d d        t              S # 1 sw Y   xY w# 1 sw Y   t              S xY w)NB)
memoryviewcastreadlen)r	   bview	byte_viewdatas        r
   readintozDecompressReader.readintoB   sv    ] 	)dDIIcN 	)i99S^,D$(Ijs4y!	) 	) 4y	) 	) 	) 4ys"   A.)A"A."A+	'A..Bc                    |dk  r| j                         S |r| j                  ryd }	 | j                  j                  ry| j                  j                  xs | j
                  j                  t              }|sn | j                  di | j                  | _        	 | j                  j                  ||      }n`| j                  j                  r,| j
                  j                  t              }|st        d      d}| j                  j                  ||      }|rn|sd| _        | j                  | _        y| xj                  t!        |      z  c_        |S # | j                  $ r Y Lw xY w)Nr   r   TzACompressed file ended before the end-of-stream marker was reachedr   )readallr#   r(   eofunused_datar"   r9   BUFFER_SIZEr&   r'   
decompressr)   needs_inputEOFErrorr$   r%   r:   )r	   sizer>   rawblocks       r
   r9   zDecompressReader.readH   sY   !8<<>!tyy !!%% ..:: 7 HHMM+6 %9T%9%9 &)''&)"--884HD
 %%11#xx}}[9H#& (J K K  #H))44XtD1 2 DIDJ		SY	' ++ s   E E('E(c                     g }| j                  t        j                        x}r3|j                  |       | j                  t        j                        x}r3dj	                  |      S )Nr   )r9   sysmaxsizeappendjoin)r	   chunksr>   s      r
   rA   zDecompressReader.readallq   sX     ii,,d,MM$ ii,,d, xxr   c                     | j                   j                  d       d| _        d| _         | j                  di | j
                  | _        y )Nr   Fr   )r"   seekr#   r$   r&   r'   r(   r   s    r
   _rewindzDecompressReader._rewind|   s>    a		1T11FD4E4EFr   c                    |t         j                  k(  rn|t         j                  k(  r| j                  |z   }n|t         j                  k(  r_| j
                  dk  r@| j                  t         j                        r!	 | j                  t         j                        r!| j
                  |z   }nt        dj                  |            || j                  k  r| j                          n|| j                  z  }|dkD  rL| j                  t        t         j                  |            }|s	 | j                  S |t        |      z  }|dkD  rL| j                  S )Nr   zInvalid value for whence: {})r   SEEK_SETSEEK_CURr$   SEEK_ENDr%   r9   DEFAULT_BUFFER_SIZEr   formatrR   minr:   )r	   offsetwhencer>   s       r
   rQ   zDecompressReader.seek   s   R[[ r{{"YY'Fr{{"zzA~ii 6 67 ii 6 67ZZ&(F;BB6JKK DIILLNdiiF qj99S!7!7@AD yy c$iF	 qj yyr   c                     	 | j                   S r0   )r$   r   s    r
   tellzDecompressReader.tell   s    /yyr   )r   )r!   )r   r   r   r   r.   r2   r   r?   r9   rA   rR   r   rT   rQ   r]   __classcell__)r3   s   @r
   r   r   !   sC    ?.(#'R G #%++ <r   r   )r   rK   rW   rD   BufferedIOBaser   	RawIOBaser   r   r   r
   <module>ra      s?    = 	 
$$F"" F0Ar|| Ar   