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: //opt/osm/venv/lib/python3.10/site-packages/pip/_internal/network/__pycache__/cache.cpython-310.pyc
o

5i��@s�dZddlmZddlZddlZddlmZddlmZddl	m	Z	ddl
mZmZm
Z
ddlmZdd	lmZdd
lmZddlmZmZmZddlmZddd�Zeddd��ZGdd�de�ZdS)zHTTP cache implementation.�)�annotationsN)�	Generator)�contextmanager)�datetime)�Any�BinaryIO�Callable)�SeparateBodyBaseCache)�SeparateBodyFileCache)�Response)�adjacent_tmp_file�copy_directory_permissions�replace)�
ensure_dir�responser�return�boolcCst|dd�S)N�
from_cacheF)�getattr)r�r�I/opt/osm/venv/lib/python3.10/site-packages/pip/_internal/network/cache.py�
is_from_cachesr�Generator[None, None, None]ccs$�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��rcs�eZdZdZd-�fdd�Zd.d	d
�Zd/d
d�Zd0dd�Zd1dd�Zd2dd�Z		d3d4d d!�Z
d5d"d#�Zd6d%d&�Zd7d(d)�Z
d8d+d,�Z�ZS)9�
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.
    �	directory�strr�Nonecs$|dusJd��t���||_dS)Nz!Cache directory must not be None.)�super�__init__r)�selfr��	__class__rrr 9s

zSafeFileCache.__init__�namecCs6t�|�}t|dd��|g}tjj|jg|�R�S)N�)r
�encode�list�os�path�joinr)r!r$�hashed�partsrrr�_get_cache_path>s
zSafeFileCache._get_cache_path�key�bytes | Nonec	Cs�|�|�}|d}tj�|�rtj�|�sdSt��)t|d��}|��Wd�Wd�S1s6wYWd�dS1sFwYdS�N�.body�rb)r-r(r)�existsr�open�read)r!r.�
metadata_path�	body_path�frrr�getFs
��"�zSafeFileCache.getr)�writer_func�Callable[[BinaryIO], Any]c	Cs�t��5ttj�|��t|��}||�t|j|�Wd�n1s%wYt|j	|�Wd�dS1s;wYdS)zICommon file writing logic with proper permissions and atomic replacement.N)
rrr(r)�dirnamerr
rrr$)r!r)r:r8rrr�_write_to_filePs
�"�zSafeFileCache._write_to_file�data�bytesc�|�|�fdd��dS)Ncs
|���S�N)�write�r8�r>rr�<lambda>^s
z&SafeFileCache._write.<locals>.<lambda>�r=)r!r)r>rrDr�_write]�zSafeFileCache._write�source_filercr@)Ncst��|�SrA)�shutil�copyfileobjrC�rIrrrEasz.SafeFileCache._write_from_io.<locals>.<lambda>rF)r!r)rIrrLr�_write_from_io`rHzSafeFileCache._write_from_ioN�value�expires�int | datetime | NonecCs|�|�}|�||�dSrA�r-rG)r!r.rNrOr)rrr�setcs
zSafeFileCache.setcCst|�|�}t��
t�|�Wd�n1swYt��t�|d�Wd�dS1s3wYdS�Nr1)r-rr(�remove)r!r.r)rrr�deleteis
�"�zSafeFileCache.delete�BinaryIO | NonecCsb|�|�}|d}tj�|�rtj�|�sdSt��
t|d�Wd�S1s*wYdSr0)r-r(r)r3rr4)r!r.r6r7rrr�get_bodyps
$�zSafeFileCache.get_body�bodycCs|�|�d}|�||�dSrSrQ)r!r.rXr)rrr�set_bodyyszSafeFileCache.set_body�	body_filecCs|�|�d}|�||�dS)z3Set the body of the cache entry from a file object.r1N)r-rM)r!r.rZr)rrr�set_body_from_io}szSafeFileCache.set_body_from_io)rrrr)r$rrr)r.rrr/)r)rr:r;rr)r)rr>r?rr)r)rrIrrrrA)r.rrNr?rOrPrr)r.rrr)r.rrrV)r.rrXr?rr)r.rrZrrr)�__name__�
__module__�__qualname__�__doc__r r-r9r=rGrMrRrUrWrYr[�
__classcell__rrr"rr's





�


	r)rrrr)rr)r_�
__future__rr(rJ�collections.abcr�
contextlibrr�typingrrrZpip._vendor.cachecontrol.cacher	�pip._vendor.cachecontrol.cachesr
Zpip._vendor.requests.modelsr�pip._internal.utils.filesystemrr
r�pip._internal.utils.miscrrrrrrrr�<module>s"