B Re @sdZddlZddlmZddlmZddlmZddlm Z ddl m Z m Z ddl mZdd lmZerxdd lmZmZd d Zed dZGdddeZdS)zHTTP cache implementation. N)contextmanager) BaseCache) FileCache)Response)adjacent_tmp_filereplace) ensure_dir)MYPY_CHECK_RUNNING)OptionalIteratorcCs t|ddS)N from_cacheF)getattr)responser/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/network/cache.py is_from_cachesrc cs(y dVWnttfk r"YnXdS)zvIf we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. N)OSErrorIOErrorrrrrsuppressed_cache_errorss rcs@eZdZdZfddZddZddZdd Zd d ZZ S) SafeFileCachezw A file based cache which is safe to use even when the target directory may not be accessible or writable. cs(|dk stdtt|||_dS)Nz!Cache directory must not be None.)AssertionErrorsuperr__init__ directory)selfr) __class__rrr*szSafeFileCache.__init__cCs4t|}t|dd|g}tjj|jf|S)N)rencodelistospathjoinr)rnamehashedpartsrrr_get_cache_path0s zSafeFileCache._get_cache_pathc Cs:||}t t|d }|SQRXWdQRXdS)Nrb)r%ropenread)rkeyr frrrget9s  zSafeFileCache.getc CsZ||}t@ttj|t|}||WdQRXt|j |WdQRXdS)N) r%rrrr dirnamerwriterr")rr)valuer r*rrrset@s   zSafeFileCache.setc Cs*||}tt|WdQRXdS)N)r%rrremove)rr)r rrrdeleteKs zSafeFileCache.delete) __name__ __module__ __qualname____doc__rr%r+r/r1 __classcell__rr)rrr$s    r)r5r contextlibrZpip._vendor.cachecontrol.cacherpip._vendor.cachecontrol.cachesrZpip._vendor.requests.modelsrpip._internal.utils.filesystemrrpip._internal.utils.miscrpip._internal.utils.typingr typingr r rrrrrrrs