U .e@sdZddlZddlmZddlmZddlmZddlm Z m Z ddl m Z ddl mZerhdd lmZed d ZGd d d eZdS)zHTTP cache implementation. N)contextmanager) BaseCache) FileCache)adjacent_tmp_filereplace) ensure_dir)MYPY_CHECK_RUNNING)Optionalc cs(z 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)OSErrorIOErrorr r ?/usr/lib/python3.8/site-packages/pip/_internal/network/cache.pysuppressed_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. cstt|||_dSN)superr__init__ directory)selfr __class__r r r&szSafeFileCache.__init__cCs4t|}t|dd|g}tjj|jf|S)N)rencodelistospathjoinr)rnameZhashedpartsr r r _get_cache_path,s zSafeFileCache._get_cache_pathc CsR||}t8t|d"}|W5QRW5QRSQRXW5QRXdS)Nrb)rropenread)rkeyrfr r r get5s  zSafeFileCache.getc CsZ||}t@ttj|t|}||W5QRXt|j |W5QRXdSr) rrrrrdirnamerwriterr)rr#valuerr$r r r set<s   zSafeFileCache.setc Cs*||}tt|W5QRXdSr)rrrremove)rr#rr r r deleteGs zSafeFileCache.delete) __name__ __module__ __qualname____doc__rrr%r)r+ __classcell__r r rr r s    r)r/r contextlibrZpip._vendor.cachecontrol.cacherZpip._vendor.cachecontrol.cachesrZpip._internal.utils.filesystemrrZpip._internal.utils.miscrZpip._internal.utils.typingrtypingr rrr r r r s