a Ra4@sdZddlZddlmZddlmZmZddlmZddl m Z ddl m Z ddl mZmZdd lmZe ed d d Zeedd ddZGdddeZdS)zHTTP cache implementation. N)contextmanager)IteratorOptional) BaseCache) FileCache)Response)adjacent_tmp_filereplace) ensure_dir)responsereturncCs t|ddS)NZ from_cacheF)getattr)r rL/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/network/cache.py is_from_cachesr)r ccs"z dVWntyYn0dS)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  rcsneZdZdZeddfdd ZeedddZeeed d d Z eedd d dZ edd ddZ Z S) SafeFileCachezw A file based cache which is safe to use even when the target directory may not be accessible or writable. N) directoryr cs$|dusJdt||_dS)Nz!Cache directory must not be None.)super__init__r)selfr __class__rrr%s zSafeFileCache.__init__)namer cCs6t|}t|dd|g}tjj|jg|RS)N)rencodelistospathjoinr)rrZhashedpartsrrr_get_cache_path*s zSafeFileCache._get_cache_path)keyr c Cst||}tPt|d&}|WdWdS1sH0YWdn1sf0YdS)Nrb)r"ropenread)rr#rfrrrget2s  zSafeFileCache.get)r#valuer c Cs||}t^ttj|t|}||Wdn1sJ0Yt|j |Wdn1st0YdSN) r"rr rrdirnamerwriter r)rr#r)rr'rrrset8s   (zSafeFileCache.setcCs>||}tt|Wdn1s00YdSr*)r"rrremove)rr#rrrrdeleteBs zSafeFileCache.delete) __name__ __module__ __qualname____doc__strrr"rbytesr(r-r/ __classcell__rrrrrs  r)r3r contextlibrtypingrrZpip._vendor.cachecontrol.cacherZpip._vendor.cachecontrol.cachesrZpip._vendor.requests.modelsrZpip._internal.utils.filesystemrr Zpip._internal.utils.miscr boolrrrrrrrs