җnܸx p d dl mZ d dlZd dlmZ d dlmZmZmZ erd dl m
Z
d dlmZ G d d Z
dS ) )annotationsN)NamedTemporaryFile)
TYPE_CHECKINGAnyCallable)Buffer)HTTPResponsec D e Zd ZdZddZddZddZddZdddZddZ dS )CallbackFileWrappera
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.
The data is stored in a temporary file until it is all available. As long
as the temporary files directory is disk-based (sometimes it's a
memory-backed-``tmpfs`` on Linux), data will be unloaded to disk if memory
pressure is high. For small files the disk usually won't be used at all,
it'll all be in the filesystem memory cache, so there should be no
performance impact.
fpr callbackCallable[[Buffer], None] | NonereturnNonec N t dd | _ || _ || _ d S )Nzrb+T)delete)r _CallbackFileWrapper__buf_CallbackFileWrapper__fp_CallbackFileWrapper__callback)selfr r
s /builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/cachecontrol/filewrapper.py__init__zCallbackFileWrapper.__init__" s* (d;;;
" namestrr c L | d }t || S )Nr )__getattribute__getattr)r r r s r __getattr__zCallbackFileWrapper.__getattr__) s(
"
"#=
>
>r4 r boolc | j j d u S # t $ r Y nw xY w | j j }|S # t $ r Y nw xY wdS )NF)r r AttributeErrorclosed)r r# s r __is_fp_closedz"CallbackFileWrapper.__is_fp_closed5 sq 9<4'' D 9+FM D
us
/
<<c ~ | j r| j dk rd}n`| j dd t t j | j dt
j }| | d | _ | j d S )Nr r )access) r r tellseek
memoryviewmmapfilenoACCESS_READclose)r results r _closezCallbackFileWrapper._closeG s ?
$z A%%
1%%%#Idj//111T=MNNN
OOF###
r Namt
int | Nonebytesc | j | }|r| j | | r| |S N)r readr write"_CallbackFileWrapper__is_fp_closedr/ r r0 datas r r5 zCallbackFileWrapper.readc s[ innS)) #
JT""" KKMMMr intc | j | }|dk r|dk r|S | j | | r| |S )N s
)r
_safe_readr r6 r7 r/ r8 s r r= zCallbackFileWrapper._safe_readn sk i**3//!88 K
KKMMMr )r r r
r r r )r r r r )r r )r r r4 )r0 r1 r r2 )r0 r: r r2 )
__name__
__module____qualname____doc__r r r7 r/ r5 r= r r r r s $# # # #
!
!
!
! $ 8 r r )
__future__r r* tempfiler typingr r r collections.abcr http.clientr r rB r r