2bi_ S r SSKrSSKJr SSKJr SSKJrJrJrJ r SSK Jr SSKJ r SSKJr SS KJrJr SS KJr S\S\4S jr\S\S 4S j5 r " S S\5 rg)zHTTP cache implementation. N)contextmanager)datetime)BinaryIO GeneratorOptionalUnion)SeparateBodyBaseCache)SeparateBodyFileCache)Response)adjacent_tmp_filereplace) ensure_dirresponsereturnc [ U SS5 $ )N from_cacheF)getattr)r s ڍ/builddir/build/BUILDROOT/alt-python313-pip-23.3.1-3.el8.x86_64/opt/alt/python313/lib/python3.13/site-packages/pip/_internal/network/cache.py is_from_cacher s 8\511 )NNNc # 6 # Sv g! [ a gf = f7f)znIf we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. N)OSError r r suppressed_cache_errorsr s s c ^ \ rS rSrSrS\SS4U 4S jjrS\S\4S jrS \S\\ 4S jr S\S\ SS4S jr SS \S\ S\\ \S4 SS4S jjrS \SS4S jrS \S\\ 4S jrS \S\ SS4S jrSrU =r$ ) SafeFileCache a 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. directoryr Nc B > Uc S5 e[ TU ] 5 Xl g )Nz!Cache directory must not be None.)super__init__r )selfr __class__s r r! SafeFileCache.__init__2 s% $I&II$ "r namec [ R " U5 n[ US S 5 U/- n[ R R " U R /UQ76 $ )N )r encodelistospathjoinr )r" r% hashedpartss r _get_cache_pathSafeFileCache._get_cache_path7 sG '--d3VBQZ F8+ww||DNN3U33r keyc U R U5 nUS- n[ R R U5 ( a$ [ R R U5 ( d g [ 5 [ US5 nUR 5 sS S S 5 sS S S 5 $ ! , ( d f O= f S S S 5 g ! , ( d f g = fN.bodyrb)r/ r* r+ existsr openread)r" r1 metadata_path body_pathfs r getSafeFileCache.get? s ,,S1 !G+ }--"''..2K2K $ &mT*avvx +* ' &*** ' & &s$ * B57B B5 B( $B55 Cr+ datac 4 [ 5 [ [ R R U5 5 [ U5 nUR U5 S S S 5 [ WR U5 S S S 5 g ! , ( d f N-= f! , ( d f g = fN) r r r* r+ dirnamer writer r% )r" r+ r> r; s r _writeSafeFileCache._writeI sa $ &rwwt,-"4(A ) AFFD! ' & )( ' &s" 4B A8B 8 B B Bvalueexpiresc H U R U5 nU R XB5 g r@ r/ rC )r" r1 rE rF r+ s r setSafeFileCache.setR s ##C(D r c U R U5 n[ 5 [ R " U5 S S S 5 [ 5 [ R " US- 5 S S S 5 g ! , ( d f N;= f! , ( d f g = fNr4 )r/ r r* remove)r" r1 r+ s r deleteSafeFileCache.deleteX sV ##C( $ &IIdO ' $ &IIdWn% ' & ' & & &s A(A9( A69 Bc " U R U5 nUS- n[ R R U5 ( a$ [ R R U5 ( d g [ 5 [ US5 sS S S 5 $ ! , ( d f g = fr3 )r/ r* r+ r6 r r7 )r" r1 r9 r: s r get_bodySafeFileCache.get_body_ s` ,,S1 !G+ }--"''..2K2K $ & 4( ' & &s *B Bbodyc N U R U5 S- nU R X25 g rL rH )r" r1 rS r+ s r set_bodySafeFileCache.set_bodyh s# ##C(72Dr )r r@ )__name__ __module____qualname____firstlineno____doc__strr! r/ r bytesr<