3 ”Re ã@s dZddlZddlmZddlmZddlmZddlm Z ddl m Z m Z ddl mZdd lmZerxdd lmZmZd d „Zed d„ƒZGdd„deƒZdS)zHTTP cache implementation. éN)Úcontextmanager)Ú BaseCache)Ú FileCache)ÚResponse)Úadjacent_tmp_fileÚreplace)Ú ensure_dir)ÚMYPY_CHECK_RUNNING)ÚOptionalÚIteratorcCs t|ddƒS)NÚ from_cacheF)Úgetattr)Úresponse©rúŠ/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/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)ÚOSErrorÚIOErrorrrrrÚsuppressed_cache_errorss rcs@eZdZdZ‡fdd„Zdd„Zdd„Zdd „Zd d „Z‡Z S) Ú SafeFileCachezw A file based cache which is safe to use even when the target directory may not be accessible or writable. cs(|dk stdƒ‚tt|ƒjƒ||_dS)Nz!Cache directory must not be None.)ÚAssertionErrorÚsuperrÚ__init__Ú directory)Úselfr)Ú __class__rrr*szSafeFileCache.__init__cCs4tj|ƒ}t|dd…ƒ|g}tjj|jf|žŽS)Né)rÚencodeÚlistÚosÚpathÚjoinr)rÚnameÚhashedÚpartsrrrÚ_get_cache_path0s zSafeFileCache._get_cache_pathcCs:|j|ƒ}tƒ� t|dƒ� }|jƒSQRXWdQRXdS)NÚrb)r%rÚopenÚread)rÚkeyr ÚfrrrÚget9s  zSafeFileCache.getcCsZ|j|ƒ}tƒ�@ttjj|ƒƒt|ƒ�}|j|ƒWdQRXt|j |ƒWdQRXdS)N) r%rrrr ÚdirnamerÚwriterr")rr)Úvaluer r*rrrÚset@s   zSafeFileCache.setc Cs*|j|ƒ}tƒ�tj|ƒWdQRXdS)N)r%rrÚremove)rr)r rrrÚdeleteKs zSafeFileCache.delete) Ú__name__Ú __module__Ú __qualname__Ú__doc__rr%r+r/r1Ú __classcell__rr)rrr$s    r)r5rÚ contextlibrZpip._vendor.cachecontrol.cacherÚpip._vendor.cachecontrol.cachesrZpip._vendor.requests.modelsrÚpip._internal.utils.filesystemrrÚpip._internal.utils.miscrÚpip._internal.utils.typingr Útypingr r rrrrrrrÚs