idadZddlZddlmZddlmZmZddlmZddl m Z ddl m Z ddl mZmZdd lmZd e d efd Zed ed fdZGddeZdS)zHTTP cache implementation. N)contextmanager) GeneratorOptional) BaseCache) FileCache)Response)adjacent_tmp_filereplace) ensure_dirresponsereturnc$t|ddS)N from_cacheF)getattr)r s P/opt/cloudlinux/venv/lib/python3.11/site-packages/pip/_internal/network/cache.py is_from_cachers 8\5 1 11)NNNc#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  c eZdZdZdeddffd ZdedefdZdedeefd Z dded ed ee ddfd Z deddfd Z xZ S) SafeFileCachezw A file based cache which is safe to use even when the target directory may not be accessible or writable. directoryr NcVt||_dSN)super__init__r)selfr __class__s rrzSafeFileCache.__init__%s$ "rnamectj|}t|dd|gz}tjj|jg|RS)N)rencodelistospathjoinr)rr!hashedpartss r_get_cache_pathzSafeFileCache._get_cache_path*sL!$''VBQBZ  F8+w|DN3U3333rkeyc||}t5t|d5}|cdddcdddS#1swxYwY ddddS#1swxYwYdS)Nrb)r+ropenread)rr,r'fs rgetzSafeFileCache.get2s##C(( $ & &  dD!! Qvvxx                                          s4A;A" A;"A& &A;)A& *A;;A?A?valueexpirescx||}t5ttj|t |5}||dddn #1swxYwYt|j |ddddS#1swxYwYdSr) r+rr r&r'dirnamer writer r!)rr,r3r4r'r1s rsetzSafeFileCache.set8s$##C(( $ & & " " rwt,, - - -"4(( A                AFD ! ! !  " " " " " " " " " " " " " " " " " "s5rLs' %%%%%%&&&&&&&&444444555555000000EEEEEEEE//////2H22222 +;!<    &&&&&I&&&&&r