U ��.e��@s�dZddlZddlmZddlmZddlmZddlm Z m Z ddl m Z ddl mZerhdd lmZed d ��ZGd d �d e�ZdS)zHTTP cache implementation. �N)�contextmanager)� BaseCache)� FileCache)�adjacent_tmp_file�replace)� 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)�OSError�IOError�r r �?/usr/lib/python3.8/site-packages/pip/_internal/network/cache.py�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|���||_dS)Nz!Cache directory must not be None.)�AssertionError�superr�__init__� directory)�selfr�� __class__r r r&szSafeFileCache.__init__cCs4t�|�}t|dd��|g}tjj|jf|��S)N�)r�encode�list�os�path�joinr)r�nameZhashed�partsr r r �_get_cache_path,s zSafeFileCache._get_cache_pathc CsR|�|�}t��8t|d��"}|��W5QR�W5QR�SQRXW5QRXdS)N�rb)rr�open�read)r�keyr�fr r r �get5s  zSafeFileCache.getc CsZ|�|�}t��@ttj�|��t|��}|�|�W5QRXt|j |�W5QRXdS�N) rrrrr�dirnamer�writerr)rr#�valuerr$r r r �set<s   zSafeFileCache.setc Cs*|�|�}t��t�|�W5QRXdSr&)rrr�remove)rr#rr r r �deleteGs zSafeFileCache.delete) �__name__� __module__� __qualname__�__doc__rrr%r*r,� __classcell__r r rr r s    r)r0r� contextlibrZpip._vendor.cachecontrol.cacherZpip._vendor.cachecontrol.cachesrZpip._internal.utils.filesystemrrZpip._internal.utils.miscrZpip._internal.utils.typingr�typingr rrr r r r �s