HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/pip/_internal/__pycache__/cache.cpython-310.pyc
o

�N�g�(�@s,dZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZddlm
Z
mZmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZmZddlmZe�e �Z!d
Z"de	e#e#fde#fdd�Z$Gdd�d�Z%Gdd�de%�Z&Gdd�de&�Z'Gdd�d�Z(Gdd�de%�Z)dS)zCache Management
�N)�Path)�Any�Dict�List�Optional)�Tag�interpreter_name�interpreter_version)�canonicalize_name)�InvalidWheelFilename)�	DirectUrl)�Link)�Wheel)�
TempDirectory�
tempdir_kinds)�path_to_urlzorigin.json�d�returncCs&tj|dddd�}t�|�d����S)z'Return a stable sha224 of a dictionary.T)�,�:)�	sort_keys�
separators�ensure_ascii�ascii)�json�dumps�hashlib�sha224�encode�	hexdigest)r�s�r!�G/opt/saltstack/salt/lib/python3.10/site-packages/pip/_internal/cache.py�
_hash_dictsr#cs�eZdZdZdeddf�fdd�Zdedeefdd	�Zded
edee	fdd�Z
dedefd
d�Zdedeedee
defdd�Z�ZS)�CachezuAn abstract class - provides cache directories for data from links

    :param cache_dir: The root of the cache.
    �	cache_dirrNcs,t���|rtj�|�sJ�|pd|_dS�N)�super�__init__�os�path�isabsr%��selfr%��	__class__r!r"r(&s
zCache.__init__�linkcCs�d|ji}|jdur|jdur|j||j<|jr|j|d<t�|d<t�|d<t|�}|dd�|dd�|dd�|dd�g}|S)	z<Get parts of part that must be os.path.joined with cache_dir�urlNZsubdirectoryrr	���)Zurl_without_fragmentZ	hash_name�hashZsubdirectory_fragmentrr	r#)r-r0Z	key_partsZhashed�partsr!r!r"�_get_cache_path_parts+s



,zCache._get_cache_path_parts�canonical_package_namecsN|jp	|p	|}|rgS|�|��tj���r%�fdd�t���D�SgS)Ncsg|]}|�f�qSr!r!)�.0�	candidate�r*r!r"�
<listcomp>Ssz)Cache._get_candidates.<locals>.<listcomp>)r%�get_path_for_linkr)r*�isdir�listdir)r-r0r8Z
can_not_cacher!r;r"�_get_candidatesLs
zCache._get_candidatescC�t��)z5Return a directory to store cached items in for link.��NotImplementedError�r-r0r!r!r"r=VszCache.get_path_for_link�package_name�supported_tagscCrA)zaReturns a link to a cached item if it exists, otherwise returns the
        passed link.
        rB)r-r0rErFr!r!r"�getZs	z	Cache.get)�__name__�
__module__�__qualname__�__doc__�strr(r
rr7rr@r=rrrG�
__classcell__r!r!r.r"r$ s!
����r$cs^eZdZdZdeddf�fdd�Zdedefdd	�Zded
eede	e
defdd
�Z�ZS)�SimpleWheelCachez&A cache of wheels for future installs.r%rNcst��|�dSr&)r'r(r,r.r!r"r(iszSimpleWheelCache.__init__r0cCs,|�|�}|js
J�tjj|jdg|�R�S)a�Return a directory to store cached wheels for link

        Because there are M wheels for any one sdist, we provide a directory
        to cache them in, and then consult that directory when looking up
        cache hits.

        We only insert things into the cache if they have plausible version
        numbers, so that we don't contaminate the cache with things that were
        not unique. E.g. ./package might have dozens of installs done for it
        and build a version of 0.0...and if we built and cached a wheel, we'd
        end up using the same wheel even if the source has been edited.

        :param link: The link of the sdist for which this will cache wheels.
        Zwheels)r7r%r)r*�join)r-r0r6r!r!r"r=ls

z"SimpleWheelCache.get_path_for_linkrErFc
	Cs�g}|s|St|�}|�||�D]5\}}zt|�}Wn	ty#Yqwt|j�|kr4t�d|||�q|�|�s:q|�|�	|�||f�q|sJ|St
|�\}	}}ttt
j�||���S)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)r
r@rr�name�logger�debugZ	supported�appendZsupport_index_min�minr
rr)r*rO)
r-r0rErFZ
candidatesr8Z
wheel_nameZ	wheel_dirZwheel�_r!r!r"rG�s<��
��zSimpleWheelCache.get)
rHrIrJrKrLr(r
r=rrrrGrMr!r!r.r"rNfs����rNcs"eZdZdZd�fdd�Z�ZS)�EphemWheelCachezBA SimpleWheelCache that creates it's own temporary cache directoryrNcs$ttjdd�|_t��|jj�dS)NT)�kindZglobally_managed)rrZEPHEM_WHEEL_CACHEZ	_temp_dirr'r(r*)r-r.r!r"r(�s
�zEphemWheelCache.__init__)rN)rHrIrJrKr(rMr!r!r.r"rV�srVc@seZdZdedefdd�ZdS)�
CacheEntryr0�
persistentc
Cs�||_||_d|_t|jj�jt}|��r@z
t�	|j
dd��|_WdSty?}zt�
d||j|�WYd}~dSd}~wwdS)N�utf-8��encodingz7Ignoring invalid cache entry origin file %s for %s (%s))r0rY�originrZ	file_path�parent�ORIGIN_JSON_NAME�existsr�	from_json�	read_text�	ExceptionrQ�warning�filename)r-r0rYZorigin_direct_url_path�er!r!r"r(�s&
�����zCacheEntry.__init__N)rHrIrJr
�boolr(r!r!r!r"rX�s��rXc	s�eZdZdZdeddf�fdd�Zdedefdd	�Zdedefd
d�Zdede	ed
e
edefdd�Zdede	ed
e
ede	e
fdd�Zedededdfdd��Z�ZS)�
WheelCachez�Wraps EphemWheelCache and SimpleWheelCache into a single Cache

    This Cache allows for gracefully degradation, using the ephem wheel cache
    when a certain link is not found in the simple wheel cache first.
    r%rNcs"t��|�t|�|_t�|_dSr&)r'r(rN�_wheel_cacherV�_ephem_cacher,r.r!r"r(�s
zWheelCache.__init__r0cC�|j�|�Sr&)rir=rDr!r!r"r=��zWheelCache.get_path_for_linkcCrkr&)rjr=rDr!r!r"�get_ephem_path_for_link�rlz"WheelCache.get_ephem_path_for_linkrErFcCs |�|||�}|dur
|S|jSr&)�get_cache_entryr0)r-r0rErFZcache_entryr!r!r"rG�szWheelCache.getcCsP|jj|||d�}||urt|dd�S|jj|||d�}||ur&t|dd�SdS)z�Returns a CacheEntry with a link to a cached item if it exists or
        None. The cache entry indicates if the item was found in the persistent
        or ephemeral cache.
        )r0rErFT)rYFN)rirGrXrj)r-r0rErF�retvalr!r!r"rn�s
��zWheelCache.get_cache_entry�
download_infoc
Cs�t|�t}|��r?zt�|jdd��}Wnty.}z
t�d||�WYd}~nd}~ww|j	|j	kr?t�d|j	||j	�|j
|��dd�dS)NrZr[zPCould not read origin file %s in cache entry (%s). Will attempt to overwrite it.z�Origin URL %s in cache entry %s does not match download URL %s. This is likely a pip bug or a cache corruption issue. Will overwrite it with the new value.)rr_r`rrarbrcrQrdr1�
write_textZto_json)r%rpZorigin_pathr]rfr!r!r"�record_download_origin	s(���
�z!WheelCache.record_download_origin)rHrIrJrKrLr(r
r=rmrrrrGrXrn�staticmethodrrrrMr!r!r.r"rh�s2���
����
� rh)*rKrr�loggingr)�pathlibr�typingrrrrZpip._vendor.packaging.tagsrrr	Zpip._vendor.packaging.utilsr
Zpip._internal.exceptionsrZpip._internal.models.direct_urlrZpip._internal.models.linkr
Zpip._internal.models.wheelrZpip._internal.utils.temp_dirrrZpip._internal.utils.urlsr�	getLoggerrHrQr_rLr#r$rNrVrXrhr!r!r!r"�<module>s.
FF