o 7]hS@sdZddlZddlmZddlmZmZddlmZddl m Z ddl m Z ddl mZmZdd lmZd e d efd d Zed edfddZGdddeZdS)zHTTP cache implementation. N)contextmanager)IteratorOptional) BaseCache) FileCache)Response)adjacent_tmp_filereplace) ensure_dirresponsereturncCs t|ddS)N from_cacheF)getattr)r r=/usr/lib/python3/dist-packages/pip/_internal/network/cache.py is_from_caches rccs$zdVWdStyYdSw)zvIf we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. N)OSErrorrrrrsuppressed_cache_errorss   rc seZdZdZdeddffdd Zdedefdd Zd edeefd d Z dd ed edee ddfddZ d eddfddZ Z S) SafeFileCachezw A file based cache which is safe to use even when the target directory may not be accessible or writable. directoryr Ncs$|dusJdt||_dS)Nz!Cache directory must not be None.)super__init__r)selfr __class__rrr%s  zSafeFileCache.__init__namecCs6t|}t|dd|g}tjj|jg|RS)N)rencodelistospathjoinr)rrhashedpartsrrr_get_cache_path*s zSafeFileCache._get_cache_pathkeyc Csv||}t)t|d}|WdWdS1s$wYWddS1s4wYdS)Nrb)r$ropenread)rr%r frrrget2s  "zSafeFileCache.getvalueexpiresc Cs||}t0ttj|t| }||Wdn1s%wYt|j |WddS1s;wYdSN) r$rr rr dirnamerwriter r)rr%r+r,r r)rrrset8s   "zSafeFileCache.setcCs@||}tt|WddS1swYdSr-)r$rrremove)rr%r rrrdeleteBs  "zSafeFileCache.deleter-)__name__ __module__ __qualname____doc__strrr$rbytesr*intr0r2 __classcell__rrrrrs  r)r6r contextlibrtypingrrpip._vendor.cachecontrol.cacherpip._vendor.cachecontrol.cachesrpip._vendor.requests.modelsrpip._internal.utils.filesystemrr pip._internal.utils.miscr boolrrrrrrrs