\h\ddlmZddlZddlmZddlmZmZmZerddl m Z GddZ y)) annotationsN)NamedTemporaryFile) TYPE_CHECKINGAnyCallable) HTTPResponsecNeZdZdZ d dZd dZd dZd dZd ddZddZ y)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. cDtdd|_||_||_y)Nzrb+T)delete)r_CallbackFileWrapper__buf_CallbackFileWrapper__fp_CallbackFileWrapper__callback)selffpcallbacks g/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_vendor/cachecontrol/filewrapper.py__init__zCallbackFileWrapper.__init__!s (d;  "c<|jd}t||S)Nr)__getattribute__getattr)rnamers r __getattr__zCallbackFileWrapper.__getattr__(s" " "#= >r4  rc |jjduS#t$rYnwxYw |jj}|S#t$rYywxYw)NF)rrAttributeErrorclosed)rrs r__is_fp_closedz"CallbackFileWrapper.__is_fp_closed4s\ 99<<4' '    99++FM    s &&A A Ac|jr|jjdk(rd}nc|jjddt t j |jj dt j}|j|d|_|jjy)Nrr)access) rr tellseek memoryviewmmapfileno ACCESS_READclose)rresults r_closezCallbackFileWrapper._closeFs ??zz A%  1%#IIdjj//11T=M=MN OOF # rNc|jj|}|r|jj||j r|j |SN)rreadr write"_CallbackFileWrapper__is_fp_closedr)ramtdatas rr,zCallbackFileWrapper.readasEiinnS)  JJ  T "    KKM rc|jj|}|dk(r|dk(r|S|jj||j r|j |S)Ns )r _safe_readr r-r.r)r/s rr4zCallbackFileWrapper._safe_readlsVii**3/ !8K     KKM r)rrrzCallable[[bytes], None] | NonereturnNone)rstrr5r)r5bool)r5r6r+)r0z int | Noner5bytes)r0intr5r9) __name__ __module__ __qualname____doc__rrr.r)r,r4rrr r s=$##*H# # !$6  rr ) __future__rr$tempfilertypingrrr http.clientrr r?rrrDs(# '//(iir