� c��j1 � � � d Z ddlZddlZej Z G d� dej � Z G d� dej � Zy)z7Internal classes used by the gzip, lzma and bz2 modules� Nc �( � e Zd ZdZd� Zd� Zd� Zd� Zy)� BaseStreamzMode-checking helper functions.c �2 � | j rt d� �y )NzI/O operation on closed file)�closed� ValueError��selfs �%/usr/lib64/python3.12/_compression.py�_check_not_closedzBaseStream._check_not_closed s � ��;�;��;�<�<� � c �N � | j � st j d� �y )NzFile not open for reading)�readable�io�UnsupportedOperationr s r �_check_can_readzBaseStream._check_can_read �" � ��}�}���)�)�*E�F�F� r c �N � | j � st j d� �y )NzFile not open for writing)�writabler r r s r �_check_can_writezBaseStream._check_can_write r r c � � | j � st j d� �| j � st 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_seekzBaseStream._check_can_seek sO � ��}�}���)�)� +F� G� G��}�}���)�)� +E� F� F� r N)�__name__� __module__�__qualname__�__doc__r r r r � r r r r s � �)�=�G�G�Fr r c �t � � e Zd ZdZd� Zdd�Z� fd�Zd� Zd� Zd d�Z d� Z d � Zej fd �Zd� Z� xZS )�DecompressReaderz5Adapts the decompressor API to a RawIOBase reader APIc � � y)NTr r s r r zDecompressReader.readable$ s � �r c � � || _ d| _ d| _ d| _ || _ || _ | j di | 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__zDecompressReader.__init__' sZ � ������ ��� � �� � .���'���1�T�1�1�F�D�4E�4E�F��� .��r c �. �� d | _ t �| � � S �N)r) �super�close)r � __class__s �r r3 zDecompressReader.close; s �� �!����w�}��r c �6 � | j j � S r1 )r# r r s r r zDecompressReader.seekable? s � ��x�x� � �"�"r c � � t |� 5 }|j d� 5 }| j t |� � }||d t |� d d d � d d d � t � S # 1 sw Y �xY w# 1 sw Y t � S xY w)N�B)� memoryview�cast�read�len)r �b�view� byte_view�datas r �readintozDecompressReader.readintoB sc � � ��]�d�D�I�I�c�N�i��9�9�S��^�,�D�$(�I�j�s�4�y�!� %3�]� �4�y�� %3�N��]� �4�y��s" �A.�)A"�A.�"A+ �'A.�.Bc �� � |dk r| j � S |r| j ryd } | j j ry| j j xs | j j t � }|sn� | j di | j ��| _ | j j ||� }n`| j j r,| j j t � }|s t d� �d}| j j ||� }|rn��|sd| _ | j | _ y| xj t! |� z c_ |S # | j $ r Y �Lw xY w)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&