o] 8dZddlmZddlZddlZddlmZddlmZddl m Z ddl m Z m Z m Z ddlmZdd lmZdd lmZdd lmZmZmZdd lmZddZeddZGddeZdS)zHTTP cache implementation.) annotationsN) Generator)contextmanager)datetime)AnyBinaryIOCallable)SeparateBodyBaseCache)SeparateBodyFileCache)Response)adjacent_tmp_filecopy_directory_permissionsreplace) ensure_dirresponser returnboolc$t|ddS)N from_cacheF)getattr)rs m/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pip/_internal/network/cache.py is_from_cachers 8\5 1 11Generator[None, None, None]c#6K dVdS#t$rYdSwxYw)zvIf we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. N)OSErrorrrsuppressed_cache_errorsrs:         s  cxeZdZdZd"fd Zd#dZd$d Zd%dZd&dZd'dZ d(d)dZ d*dZ d+dZ d,dZ d-d!ZxZS). SafeFileCacheaG A file based cache which is safe to use even when the target directory may not be accessible or writable. There is a race condition when two processes try to write and/or read the same entry at the same time, since each entry consists of two separate files (https://github.com/psf/cachecontrol/issues/324). We therefore have additional logic that makes sure that both files to be present before returning an entry; this fixes the read side of the race condition. For the write side, we assume that the server will only ever return the same data for the same URL, which ought to be the case for files pip is downloading. PyPI does not have a mechanism to swap out a wheel for another wheel, for example. If this assumption is not true, the CacheControl issue will need to be fixed. directorystrrNonecn| Jdt||_dS)Nz!Cache directory must not be None.)super__init__r!)selfr! __class__s rr&zSafeFileCache.__init__9s9$$&I$$$ "rnamectj|}t|dd|gz}tjj|jg|RS)N)r encodelistospathjoinr!)r'r)hashedpartss r_get_cache_pathzSafeFileCache._get_cache_path>sL'-d33VBQBZ  F8+w|DN3U3333rkey bytes | Nonec||}|dz}tj|rtj|sdSt 5t |d5}|cdddcdddS#1swxYwY ddddS#1swxYwYdSN.bodyrb)r3r.r/existsropenread)r'r4 metadata_path body_pathfs rgetzSafeFileCache.getFsY,,S11 !G+ }-- "'..2K2K 4 $ & &  mT** avvxx                                          s6)C:B' C'B+ +C.B+ /CCCr/ writer_funcCallable[[BinaryIO], Any]cdt5ttj|t |5}||t |j|dddn #1swxYwYt|j |ddddS#1swxYwYdS)zICommon file writing logic with proper permissions and atomic replacement.N) rrr.r/dirnamer rr!rr))r'r/rAr?s r_write_to_filezSafeFileCache._write_to_filePs# $ & & " " rwt,, - - -"4(( >A A+4>1===  > > > > > > > > > > > > > > > AFD ! ! ! " " " " " " " " " " " " " " " " " "s5z&SafeFileCache._write..^sAGGDMMrrE)r'r/rFs `r_writezSafeFileCache._write]s) D"9"9"9"9:::::r source_filerc:||fddS)Nc.tj|SrJ)shutil copyfileobj)r?rOs rrLz.SafeFileCache._write_from_io..asF,>{A,N,NrrM)r'r/rOs `r_write_from_iozSafeFileCache._write_from_io`s) D"N"N"N"NOOOOOrNvalueexpiresint | datetime | Nonec\||}|||dSrJr3rN)r'r4rUrVr/s rsetzSafeFileCache.setcs1##C(( D%     rc ||}t5tj|dddn #1swxYwYt5tj|dzddddS#1swxYwYdSNr8)r3rr.remove)r'r4r/s rdeletezSafeFileCache.deleteis##C(( $ & &   IdOOO                $ & & & & IdWn % % % & & & & & & & & & & & & & & & & & &s#AA  A BB BBinaryIO | Nonec&||}|dz}tj|rtj|sdSt 5t |dcdddS#1swxYwYdSr7)r3r.r/r:rr;)r'r4r=r>s rget_bodyzSafeFileCache.get_bodyps,,S11 !G+ }-- "'..2K2K 4 $ & & ) ) 4(( ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s)BB  B bodycb||dz}|||dSr\rY)r'r4rbr/s rset_bodyzSafeFileCache.set_bodyys4##C((72 D$r body_filecb||dz}|||dS)z3Set the body of the cache entry from a file object.r8N)r3rT)r'r4rer/s rset_body_from_iozSafeFileCache.set_body_from_io}s6##C((72 D),,,,,r)r!r"rr#)r)r"rr")r4r"rr5)r/r"rArBrr#)r/r"rFrGrr#)r/r"rOrrr#rJ)r4r"rUrGrVrWrr#)r4r"rr#)r4r"rr_)r4r"rbrGrr#)r4r"rerrr#)__name__ __module__ __qualname____doc__r&r3r@rErNrTrZr^rardrg __classcell__)r(s@rr r 's"###### 4444     " " " ";;;;PPPPHL!!!!! &&&&))))    --------rr )rr rr)rr)rk __future__rr.rRcollections.abcr contextlibrrtypingrrr pip._vendor.cachecontrol.cacher pip._vendor.cachecontrol.cachesr pip._vendor.requests.modelsr pip._internal.utils.filesystemr rrpip._internal.utils.miscrrrr rrrrvsr """""" %%%%%%%%%%%%**********@@@@@@AAAAAA000000 0/////2222    Y-Y-Y-Y-Y-)Y-Y-Y-Y-Y-r