OwlCyberSecurity - MANAGER
Edit File: cache.cpython-310.pyc
o ����ƚRe�$����������������������@���s ��d�Z�ddlZddlZddlZddlZddlmZmZmZm Z m Z �ddlmZm Z mZ�ddlmZ�ddlmZ�ddlmZ�ddlmZ�dd lmZ�dd lmZmZ�ddlmZ�e�e�Z dee!e!f�d e!fdd�Z"G�dd��d�Z#G�dd��de#�Z$G�dd��de$�Z%G�dd��d�Z&G�dd��de#�Z'dS�)zCache Management �����N)�Any�Dict�List�Optional�Set)�Tag�interpreter_name�interpreter_version)�canonicalize_name)�InvalidWheelFilename)� FormatControl)�Link)�Wheel)� TempDirectory� tempdir_kinds)�path_to_url�d�returnc�����������������C���s&���t�j|�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!�����/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/cache.py� _hash_dict���s���r#���c�����������������������s����e�Zd�ZdZdededee�ddf��fdd�Zd ede e�fd d�Z d edede e�fd d�Zd edefdd�Z d edee�de e�defdd�Z���ZS�)�Cachean��An abstract class - provides cache directories for data from links :param cache_dir: The root of the cache. :param format_control: An object of FormatControl class to limit binaries being read from the cache. :param allowed_formats: which formats of files the cache should store. ('binary' and 'source' are the only allowed values) � cache_dir�format_control�allowed_formatsr���Nc��������������������sT���t�������|rtj�|�sJ��|pd�|�_||�_||�_ddh}|�j�|�|ks(J��d�S�)N�source�binary) �super�__init__�os�path�isabsr%���r&���r'����union)�selfr%���r&���r'����_valid_formats�� __class__r!���r"���r+���(���s��� zCache.__init__�linkc�����������������C���s����d|j�i}|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�urlN�subdirectoryr���r ���������������)�url_without_fragment� hash_name�hash�subdirectory_fragmentr���r ���r#���)r0���r4���� key_parts�hashed�partsr!���r!���r"����_get_cache_path_parts4���s��� ,zCache._get_cache_path_parts�canonical_package_namec�����������������C���st���|�j��p |�p |�}|rg�S�|�j�|�}|�j�|�sg�S�g�}|��|�}tj�|�r8t� |�D�] }|� ||f��q.|S��N)r%���r&����get_allowed_formatsr'����intersection�get_path_for_linkr,���r-����isdir�listdir�append)r0���r4���rB���� can_not_cache�formats� candidatesr-���� candidater!���r!���r"����_get_candidatesU���s��� zCache._get_candidatesc�����������������C�������t����)z5Return a directory to store cached items in for link.��NotImplementedError�r0���r4���r!���r!���r"���rF���e���s���zCache.get_path_for_link�package_name�supported_tagsc�����������������C���rO���)zaReturns a link to a cached item if it exists, otherwise returns the passed link. rP���)r0���r4���rS���rT���r!���r!���r"����geti���s��� z Cache.get)�__name__� __module__�__qualname__�__doc__�strr���r���r+���r ���r���rA���r���rN���rF���r���r���rU���� __classcell__r!���r!���r2���r"���r$������s.���� ����!����r$���c�����������������������sb���e�Zd�ZdZdededdf��fdd�Zdedefd d �Zdede e�de e�defd d�Z���Z S�)�SimpleWheelCachez&A cache of wheels for future installs.r%���r&���r���Nc��������������������s���t����||dh��d�S��Nr)���)r*���r+����r0���r%���r&���r2���r!���r"���r+���x���s���zSimpleWheelCache.__init__r4���c�����������������C���s,���|���|�}|�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. �wheels)rA���r%���r,���r-����join)r0���r4���r@���r!���r!���r"���rF���{���s��� z"SimpleWheelCache.get_path_for_linkrS���rT���c����������� ��� ���C���s����g�}|s|S�t�|�}|��||�D�]5\}}zt|�}W�n �ty#���Y�qw�t�|j�|kr4t�d|||��q|�|�s:q|�|� |�||f��q|sJ|S�t |�\} }}ttt j�||���S�)NzWIgnoring cached wheel %s for %s as it does not match the expected distribution name %s.)r ���rN���r���r����name�logger�debug� supportedrI����support_index_min�minr ���r���r,���r-���r`���) r0���r4���rS���rT���rL���rB���� wheel_name� wheel_dir�wheel�_r!���r!���r"���rU�������s<����� ��zSimpleWheelCache.get)rV���rW���rX���rY���rZ���r���r+���r ���rF���r���r���r���rU���r[���r!���r!���r2���r"���r\���u���s��������r\���c�����������������������s*���e�Zd�ZdZdeddf��fdd�Z���ZS�)�EphemWheelCachezBA SimpleWheelCache that creates it's own temporary cache directoryr&���r���Nc��������������������s&���t�tjdd�|�_t���|�jj|��d�S�)NT)�kind�globally_managed)r���r����EPHEM_WHEEL_CACHE� _temp_dirr*���r+���r-���)r0���r&���r2���r!���r"���r+�������s ����zEphemWheelCache.__init__)rV���rW���rX���rY���r���r+���r[���r!���r!���r2���r"���rk�������s����rk���c�������������������@���s���e�Zd�Zdedefdd�ZdS�)� CacheEntryr4���� persistentc�����������������C���s���||�_�||�_d�S�rC���)r4���rq���)r0���r4���rq���r!���r!���r"���r+�������s��� zCacheEntry.__init__N)rV���rW���rX���r ����boolr+���r!���r!���r!���r"���rp�������s������rp���c���������������� �������s����e�Zd�ZdZdededdf��fdd�Zdedefd d �Zdedefdd�Z ded e e�dee�defdd�Z ded e e�dee�de e�fdd�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%���r&���r���Nc��������������������s,���t����||dh��t||�|�_t|�|�_d�S�r]���)r*���r+���r\����_wheel_cacherk����_ephem_cacher^���r2���r!���r"���r+�������s���zWheelCache.__init__r4���c�����������������C�������|�j��|�S�rC���)rt���rF���rR���r!���r!���r"���rF�����������zWheelCache.get_path_for_linkc�����������������C���rv���rC���)ru���rF���rR���r!���r!���r"����get_ephem_path_for_link����rw���z"WheelCache.get_ephem_path_for_linkrS���rT���c�����������������C���s ���|���|||�}|d�u�r |S�|jS�rC���)�get_cache_entryr4���)r0���r4���rS���rT����cache_entryr!���r!���r"���rU�������s���zWheelCache.getc�����������������C���sP���|�j�j|||d�}||urt|dd�S�|�jj|||d�}||ur&t|dd�S�dS�)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. )r4���rS���rT���T)rq���FN)rt���rU���rp���ru���)r0���r4���rS���rT����retvalr!���r!���r"���ry�������s��� ��zWheelCache.get_cache_entry)rV���rW���rX���rY���rZ���r���r+���r ���rF���rx���r���r���r���rU���rp���ry���r[���r!���r!���r2���r"���rs�������s.������� �����rs���)(rY���r���r����loggingr,����typingr���r���r���r���r���Zpip._vendor.packaging.tagsr���r���r ����pip._vendor.packaging.utilsr ����pip._internal.exceptionsr����#pip._internal.models.format_controlr����pip._internal.models.linkr ����pip._internal.models.wheelr����pip._internal.utils.temp_dirr���r����pip._internal.utils.urlsr���� getLoggerrV���rb���rZ���r#���r$���r\���rk���rp���rs���r!���r!���r!���r"����<module>���s*���� XF