Current File : //lib/python3.9/site-packages/pip/_internal/network/__pycache__/cache.cpython-39.pyc
a

[��f4�@s�dZddlZddlmZddlmZmZddlmZddl	m
Z
ddlmZddl
mZmZdd	lmZeed
�dd�Zeedd
�dd��ZGdd�de�ZdS)zHTTP cache implementation.
�N)�contextmanager)�Iterator�Optional)�	BaseCache)�	FileCache)�Response)�adjacent_tmp_file�replace)�
ensure_dir)�response�returncCst|dd�S)NZ
from_cacheF)�getattr)r�r�?/usr/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)�OSErrorrrrr�suppressed_cache_errorss
rcsneZdZdZedd��fdd�Zeed�dd�Zeeed	�d
d�Z	eedd�d
d�Z
edd	�dd�Z�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$|dusJd��t���||_dS)Nz!Cache directory must not be None.)�super�__init__r)�selfr��	__class__rrr%s
zSafeFileCache.__init__)�namercCs6t�|�}t|dd��|g}tjj|jg|�R�S)N�)r�encode�list�os�path�joinr)rrZhashed�partsrrr�_get_cache_path*s
zSafeFileCache._get_cache_path)�keyrc	Cst|�|�}t��Pt|d��&}|��Wd�Wd�S1sH0YWd�n1sf0YdS)N�rb)r"r�open�read)rr#r�frrr�get2s
zSafeFileCache.get)r#�valuerc	Cs�|�|�}t��^ttj�|��t|��}|�|�Wd�n1sJ0Yt|j	|�Wd�n1st0YdS�N)
r"rr
rr�dirnamer�writer	r)rr#r)rr'rrr�set8s

(zSafeFileCache.setcCs>|�|�}t��t�|�Wd�n1s00YdSr*)r"rr�remove)rr#rrrr�deleteBs
zSafeFileCache.delete)
�__name__�
__module__�__qualname__�__doc__�strrr"r�bytesr(r-r/�
__classcell__rrrrrs
r)r3r�
contextlibr�typingrrZpip._vendor.cachecontrol.cacherZpip._vendor.cachecontrol.cachesrZpip._vendor.requests.modelsrZpip._internal.utils.filesystemrr	Zpip._internal.utils.miscr
�boolrrrrrrr�<module>s