2bi f S SK Jr S SKrS SKJr S SKJrJrJr \( a S SK J
r
" S S5 rg) )annotationsN)NamedTemporaryFile)
TYPE_CHECKINGAnyCallable)HTTPResponsec d \ rS rSrSr SS jrSS jrS
S jrSS jrSSS jjr SS jr
S
rg)CallbackFileWrapper a
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.
c : [ SSS9U l Xl X l g )Nzrb+T)delete)r _CallbackFileWrapper__buf_CallbackFileWrapper__fp_CallbackFileWrapper__callback)selffpcallbacks ږ/builddir/build/BUILDROOT/alt-python313-pip-23.3.1-3.el8.x86_64/opt/alt/python313/lib/python3.13/site-packages/pip/_vendor/cachecontrol/filewrapper.py__init__CallbackFileWrapper.__init__! s (d;
" c : U R S5 n[ X!5 $ )Nr )__getattribute__getattr)r namer s r __getattr__CallbackFileWrapper.__getattr__( s
"
"#=
>r r c U R R S L $ ! [ a Of = f U R R nU$ ! [ a gf = f)NF)r r AttributeErrorclosed)r r s r __is_fp_closed"CallbackFileWrapper.__is_fp_closed4 s\ 99<<4'' 99++FM s
''A
AAc U R ( a U R R 5 S:X a SnOaU R R SS5 [ [
R
" U R R
5 S[
R S95 nU R U5 S U l U R R 5 g )Nr r )access) r r tellseek
memoryviewmmapfilenoACCESS_READclose)r results r _closeCallbackFileWrapper._closeF s ??zz A%
1%#IIdjj//11T=M=MN
OOF#
r Nc U R R U5 nU( a U R R U5 U R 5 ( a U R 5 U$ N)r readr write"_CallbackFileWrapper__is_fp_closedr- r amtdatas r r1 CallbackFileWrapper.reada sH iinnS)
JJT" KKMr c U R R U5 nUS:X a US:X a U$ U R R U5 U R 5 ( a U R 5 U$ )N s
)r
_safe_readr r2 r3 r- r4 s r r: CallbackFileWrapper._safe_readl sY ii**3/!8 K
KKMr )__buf
__callback__fp)r r r zCallable[[bytes], None] | NonereturnNone)r strr? r )r? bool)r? r@ r0 )r5 z
int | Noner? bytes)r5 intr? rC )__name__
__module____qualname____firstlineno____doc__r r r3 r- r1 r: __static_attributes__ r r r
r
s= $##*H#
#
!$6 r r
)
__future__r r( tempfiler typingr r r http.clientr r
rK r r