
    d1                     t    d Z ddlZddlZej        Z G d dej                  Z G d dej                  ZdS )z7Internal classes used by the gzip, lzma and bz2 modules    Nc                   *    e Zd ZdZd Zd Zd Zd ZdS )
BaseStreamzMode-checking helper functions.c                 2    | j         rt          d          d S )NzI/O operation on closed file)closed
ValueErrorselfs      /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/_compression.py_check_not_closedzBaseStream._check_not_closed   s%    ; 	=;<<<	= 	=    c                 V    |                                  st          j        d          d S )NzFile not open for reading)readableioUnsupportedOperationr   s    r
   _check_can_readzBaseStream._check_can_read   1    }} 	G)*EFFF	G 	Gr   c                 V    |                                  st          j        d          d S )NzFile not open for writing)writabler   r   r   s    r
   _check_can_writezBaseStream._check_can_write   r   r   c                     |                                  st          j        d          |                                 st          j        d          d S )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   sl    }} 	G) +F G G G}} 	F) +E F F F	F 	Fr   N)__name__
__module____qualname____doc__r   r   r   r    r   r
   r   r   	   sa        ))= = =G G GG G GF F F F Fr   r   c                   j     e Zd 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 )DecompressReaderz5Adapts the decompressor API to a RawIOBase reader APIc                     dS )NTr   r   s    r
   r   zDecompressReader.readable$   s    tr   r   c                     || _         d| _        d| _        d| _        || _        || _         | j        di | j        | _        || _        d S )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__'   s`    		 
  .'1T1FFD4EFF  .r   c                 R    d | _         t                                                      S N)r)   superclose)r	   	__class__s    r
   r3   zDecompressReader.close;   s    !ww}}r   c                 4    | j                                         S r1   )r#   r   r   s    r
   r   zDecompressReader.seekable?   s    x  """r   c                 4   t          |          5 }|                    d          5 }|                     t          |                    }||d t          |          <   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          |          S )NB)
memoryviewcastreadlen)r	   bview	byte_viewdatas        r
   readintozDecompressReader.readintoB   s    ]] 	)dDIIcNN 	)i99S^^,,D$(Ijs4yyj!	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 4yys4   B 7A)B )A-	-B 0A-	1B  BBr"   c                 v   |dk     r|                                  S |r| j        rdS d }	 | j        j        rr| j        j        p| j                            t                    }|sn | j        di | j	        | _        	 | j        
                    ||          }nj# | j        $ r Y nbw xY w| j        j        r1| j                            t                    }|st          d          nd}| j        
                    ||          }|rn|sd| _        | j        | _        dS | xj        t!          |          z  c_        |S )Nr   r   TzACompressed file ended before the end-of-stream marker was reachedr   )readallr$   r)   eofunused_datar#   r:   BUFFER_SIZEr'   r(   
decompressr*   needs_inputEOFErrorr%   r&   r;   )r	   sizer?   rawblocks       r
   r:   zDecompressReader.readH   s   !88<<>>! 	ty 	3	!% E .: 7 HMM+66  %9T%9 &) &)'&) &)"-884HHDD+   E %1 ##x}}[99H# K& (J K K KK  #H)44XtDD 1	2  	DIDJ3		SYY		s   ;B 
B$#B$c                     g }|                      t          j                  x}r6|                    |           |                      t          j                  x}6d                    |          S )Nr   )r:   sysmaxsizeappendjoin)r	   chunksr?   s      r
   rB   zDecompressReader.readallq   sg     ii,,,d 	 MM$ ii,,,d 	  xxr   c                     | j                             d           d| _        d| _         | j        di | j        | _        d S )Nr   Fr   )r#   seekr$   r%   r'   r(   r)   r   s    r
   _rewindzDecompressReader._rewind|   sH    a		1T1FFD4EFFr   c                 f   |t           j        k    rn|t           j        k    r| j        |z   }n|t           j        k    rU| j        dk     r?|                     t           j                  r 	 |                     t           j                   | j        |z   }n"t          d	                    |                    || j        k     r| 
                                 n
|| j        z  }|dk    rH|                     t          t           j        |                    }|sn|t          |          z  }|dk    H| j        S )Nr   zInvalid value for whence: {})r   SEEK_SETSEEK_CURr%   SEEK_ENDr&   r:   DEFAULT_BUFFER_SIZEr   formatrS   minr;   )r	   offsetwhencer?   s       r
   rR   zDecompressReader.seek   s&   R[  r{""Y'FFr{""zA~~ii 677  ii 677 Z&(FF;BB6JJKKK DILLNNNNdiF qjj99S!7@@AAD c$iiF	 qjj yr   c                     | j         S )z!Return the current file position.)r%   r   s    r
   tellzDecompressReader.tell   s
    yr   )r   )r"   )r   r   r   r   r   r/   r3   r   r@   r:   rB   rS   r   rU   rR   r^   __classcell__)r4   s   @r
   r   r   !   s        ??  . . . .(    # # #  ' ' ' 'R     G G G #%+    <      r   r   )	r   r   rL   rX   rE   BufferedIOBaser   	RawIOBaser   r   r   r
   <module>rb      s    = = 				 



$F F F F F" F F F0A A A A Ar| A A A A Ar   