hdddlmZddlZddlmZddlmZmZmZerddl m Z GddZ dS)) annotationsN)NamedTemporaryFile) TYPE_CHECKINGAnyCallable) HTTPResponsecDeZdZdZddZdd ZddZddZdddZddZ 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. fprcallbackCallable[[bytes], None] | NonereturnNonecNtdd|_||_||_dS)Nzrb+T)delete)r_CallbackFileWrapper__buf_CallbackFileWrapper__fp_CallbackFileWrapper__callback)selfr r s /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/cachecontrol/filewrapper.py__init__zCallbackFileWrapper.__init__!s*(d;;;  "namestrrcL|d}t||S)Nr)__getattribute__getattr)rrr s r __getattr__zCallbackFileWrapper.__getattr__(s( " "#= > >r4   rboolc |jjduS#t$rYnwxYw |jj}|S#t$rYnwxYwdS)NF)rr AttributeErrorclosed)rr"s r__is_fp_closedz"CallbackFileWrapper.__is_fp_closed4sq 9<4' '    D  9+FM    D  us   / <<c~|jr|jdkrd}n`|jddt t j|jdt j}||d|_|jdS)Nrr)access) rrtellseek memoryviewmmapfileno ACCESS_READclose)rresults r_closezCallbackFileWrapper._closeFs ? $z  A%%  1%%%#Idj//111T=MNNN OOF # # # rNamt int | Nonebytesc|j|}|r|j||r||SN)rreadrwrite"_CallbackFileWrapper__is_fp_closedr.rr/datas rr4zCallbackFileWrapper.readas[innS))  # J  T " " "      KKMMM rintc|j|}|dkr|dkr|S|j||r||S)Ns )r _safe_readrr5r6r.r7s rr<zCallbackFileWrapper._safe_readlski**3// !88K       KKMMM r)r rr r rr)rrrr)rr)rrr3)r/r0rr1)r/r9rr1) __name__ __module__ __qualname____doc__rrr6r.r4r<rrr r s$#### ! ! ! !$6           rr ) __future__rr)tempfilertypingrrr http.clientrr rArrrFs#""""" ''''''//////////)((((((iiiiiiiiiir