a  ze4@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)N from_cacheF)getattr)r r]/opt/bitninja-python-dojo/embedded/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)rrhashedpartsrrr_get_cache_path*s zSafeFileCache._get_cache_path)keyr c Cst||}tPt|d&}|WdWdS1sH0YWdn1sf0YdS)Nrb)r$ropenread)rr%r frrrget2s  zSafeFileCache.get)r%valuer c Cs||}t^ttj|t|}||Wdn1sJ0Yt|j |Wdn1st0YdSN) r$rr rr dirnamerwriter r)rr%r+r r)rrrset8s   (zSafeFileCache.setcCs>||}tt|Wdn1s00YdSr,)r$rrremove)rr%r rrrdeleteBs zSafeFileCache.delete) __name__ __module__ __qualname____doc__strrr$rbytesr*r/r1 __classcell__rrrrrs  r)r5r contextlibrtypingrrZpip._vendor.cachecontrol.cacherpip._vendor.cachecontrol.cachesrZpip._vendor.requests.modelsrpip._internal.utils.filesystemrr pip._internal.utils.miscr boolrrrrrrrs