HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/pip/_internal/network/__pycache__/cache.cpython-37.pyc
B

L��g_�@s�dZddlZddlmZddlmZddlmZmZmZm	Z	ddl
mZddlm
Z
ddlmZdd	lmZmZdd
lmZeed�dd
�Zeedd�dd��ZGdd�de�ZdS)zHTTP cache implementation.
�N)�contextmanager)�datetime)�BinaryIO�	Generator�Optional�Union)�SeparateBodyBaseCache)�SeparateBodyFileCache)�Response)�adjacent_tmp_file�replace)�
ensure_dir)�response�returncCst|dd�S)N�
from_cacheF)�getattr)r�r�?/tmp/pip-unpacked-wheel-hv55ucu3/pip/_internal/network/cache.py�
is_from_cachesr)NNN)rccs$y
dVWntk
rYnXdS)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
rcs�eZdZdZedd��fdd�Zeed�dd�Zeeed	�d
d�Z	eedd�d
d�Z
deeeee
dfdd�dd�Zedd	�dd�Zeeed	�dd�Zeedd�dd�Z�ZS)�
SafeFileCacheaG
    A file based cache which is safe to use even when the target directory may
    not be accessible or writable.

    There is a race condition when two processes try to write and/or read the
    same entry at the same time, since each entry consists of two separate
    files (https://github.com/psf/cachecontrol/issues/324).  We therefore have
    additional logic that makes sure that both files to be present before
    returning an entry; this fixes the read side of the race condition.

    For the write side, we assume that the server will only ever return the
    same data for the same URL, which ought to be the case for files pip is
    downloading.  PyPI does not have a mechanism to swap out a wheel for
    another wheel, for example.  If this assumption is not true, the
    CacheControl issue will need to be fixed.
    N)�	directoryrcs$|dk	std��t���||_dS)Nz!Cache directory must not be None.)�AssertionError�super�__init__r)�selfr)�	__class__rrr2s
zSafeFileCache.__init__)�namercCs4t�|�}t|dd��|g}tjj|jf|��S)N�)r	�encode�list�os�path�joinr)rr�hashed�partsrrr�_get_cache_path7s
zSafeFileCache._get_cache_path)�keyrc
Cs^|�|�}|d}tj�|�r*tj�|�s.dSt�� t|d��
}|��SQRXWdQRXdS)Nz.body�rb)r'r"r#�existsr�open�read)rr(�
metadata_path�	body_path�frrr�get?s
zSafeFileCache.get)r#�datarc
CsPt��@ttj�|��t|��}|�|�WdQRXt|j|�WdQRXdS)N)	rr
r"r#�dirnamer�writerr)rr#r1r/rrr�_writeIs

zSafeFileCache._write)r(�value�expiresrcCs|�|�}|�||�dS)N)r'r4)rr(r5r6r#rrr�setRs
zSafeFileCache.setc	CsJ|�|�}t��t�|�WdQRXt��t�|d�WdQRXdS)Nz.body)r'rr"�remove)rr(r#rrr�deleteXs

zSafeFileCache.deletec	CsJ|�|�}|d}tj�|�r*tj�|�s.dSt��t|d�SQRXdS)Nz.bodyr))r'r"r#r*rr+)rr(r-r.rrr�get_body_s
zSafeFileCache.get_body)r(�bodyrcCs|�|�d}|�||�dS)Nz.body)r'r4)rr(r;r#rrr�set_bodyhszSafeFileCache.set_body)N)�__name__�
__module__�__qualname__�__doc__�strrr'r�bytesr0r4r�intrr7r9rr:r<�
__classcell__rr)rrr s

	r)r@r"�
contextlibrr�typingrrrrZpip._vendor.cachecontrol.cacher�pip._vendor.cachecontrol.cachesr	Zpip._vendor.requests.modelsr
�pip._internal.utils.filesystemrr�pip._internal.utils.miscr
�boolrrrrrrr�<module>s