�
��^i� � �. � d dl mZ G d� de� � ZdS )� )�BytesIOc �8 � e Zd ZdZd� Zd� Zd� Zd� Zd d�Zd� Z dS )
�CallbackFileWrapperav
Small wrapper around a fp object which will tee everything read into a
buffer, and when that file is closed it will execute a callback with the
contents of that buffer.
All attributes are proxied to the underlying file object.
This class uses members with a double underscore (__) leading prefix so as
not to accidentally shadow an attribute.
c �H � t � � | _ || _ || _ d S �N)r �_CallbackFileWrapper__buf�_CallbackFileWrapper__fp�_CallbackFileWrapper__callback)�self�fp�callbacks ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/cachecontrol/filewrapper.py�__init__zCallbackFileWrapper.__init__ s � ��Y�Y��
��� �"����� c �L � | � d� � }t ||� � S )Nr )�__getattribute__�getattr)r �namer s r �__getattr__zCallbackFileWrapper.__getattr__ s( � � �
"�
"�#=�
>�
>���r�4� � � r c �~ � | j j d u S # t $ r Y nw xY w | j j S # t $ r Y nw xY wdS )NF)r r �AttributeError�closed�r s r �__is_fp_closedz"CallbackFileWrapper.__is_fp_closed! sm � � ��9�<�4�'�'��� � � ��D� ���� ��9�#�#��� � � ��D� ����
�us �
�
��- �
:�:c �z � | j r,| � | j � � � � � d | _ d S r )r
r �getvaluer s r �_closezCallbackFileWrapper._close2 s9 � ��?� 3��O�O�D�J�/�/�1�1�2�2�2� ����r Nc � � | j � |� � }| j � |� � | � � � r| � � � |S r )r �readr �write�"_CallbackFileWrapper__is_fp_closedr �r �amt�datas r r zCallbackFileWrapper.read= sQ � ��y�~�~�c�"�"���
���������� � � ��K�K�M�M�M��r c �� � | j � |� � }|dk r|dk r|S | j � |� � | � � � r| � � � |S )N� s
)r �
_safe_readr r r! r r" s r r' zCallbackFileWrapper._safe_readE sk � ��y�#�#�C�(�(���!�8�8����� �K��
���������� � � ��K�K�M�M�M��r r )
�__name__�
__module__�__qualname__�__doc__r r r! r r r' � r r r r s} � � � � � � � �#� #� #�
!�
!�
!�� � �" � � �� � � �� � � � r r N)�ior �objectr r, r r �