HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_internal/network/__pycache__/cache.cpython-310.pyc
o

@%NeS�@s�dZddlZddlmZddlmZmZddlmZddl	m
Z
ddlmZddl
mZmZdd	lmZd
edefdd
�Zededfdd��ZGdd�de�ZdS)zHTTP cache implementation.
�N)�contextmanager)�Iterator�Optional)�	BaseCache)�	FileCache)�Response)�adjacent_tmp_file�replace)�
ensure_dir�response�returncCst|dd�S)N�
from_cacheF)�getattr)r�r�=/usr/lib/python3/dist-packages/pip/_internal/network/cache.py�
is_from_cachesrccs$�zdVWdStyYdSw)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��rc	s�eZdZdZdeddf�fdd�Zdedefdd	�Zd
edeefdd�Z	dd
ed
edee
ddfdd�Zd
eddfdd�Z�Z
S)�
SafeFileCachezw
    A file based cache which is safe to use even when the target directory may
    not be accessible or writable.
    �	directoryrNcs$|dusJd��t���||_dS)Nz!Cache directory must not be None.)�super�__init__r)�selfr��	__class__rrr%s

zSafeFileCache.__init__�namecCs6t�|�}t|dd��|g}tjj|jg|�R�S)N�)r�encode�list�os�path�joinr)rr�hashed�partsrrr�_get_cache_path*s
zSafeFileCache._get_cache_path�keyc	Csv|�|�}t��)t|d��}|��Wd�Wd�S1s$wYWd�dS1s4wYdS)N�rb)r$r�open�read)rr%r �frrr�get2s
��"�zSafeFileCache.get�value�expiresc	Cs�|�|�}t��0ttj�|��t|��
}|�|�Wd�n1s%wYt|j	|�Wd�dS1s;wYdS�N)
r$rr
rr �dirnamer�writer	r)rr%r+r,r r)rrr�set8s

�"�zSafeFileCache.setcCs@|�|�}t��t�|�Wd�dS1swYdSr-)r$rr�remove)rr%r rrr�deleteBs
"�zSafeFileCache.deleter-)�__name__�
__module__�__qualname__�__doc__�strrr$r�bytesr*�intr0r2�
__classcell__rrrrrs 
r)r6r�
contextlibr�typingrr�pip._vendor.cachecontrol.cacher�pip._vendor.cachecontrol.cachesr�pip._vendor.requests.modelsr�pip._internal.utils.filesystemrr	�pip._internal.utils.miscr
�boolrrrrrrr�<module>s