관리-도구
편집 파일: cache.cpython-38.pyc
U ʗRea � @ s� d Z ddlZddlmZ ddlmZmZ ddlmZ ddl m Z ddlmZ ddl mZmZ dd lmZ eed �dd�Zeed d�dd��ZG dd� de�ZdS )zHTTP cache implementation. � N)�contextmanager)� Generator�Optional)� BaseCache)� FileCache)�Response)�adjacent_tmp_file�replace)� ensure_dir)�response�returnc C s t | dd�S )N� from_cacheF)�getattr)r � r ��/builddir/build/BUILDROOT/alt-python38-pip-22.2.1-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/network/cache.py� is_from_cache s r )NNN)r c c s$ z dV W n t k r Y nX dS )zvIf we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. N)�OSErrorr r r r �suppressed_cache_errors s r c sv e Zd ZdZedd�� fdd�Zeed�dd�Zeee d �d d�Z deeee dd�d d�Zedd �dd�Z� Z S )� SafeFileCachezw A file based cache which is safe to use even when the target directory may not be accessible or writable. N)� directoryr c s$ |d k st d��t� �� || _d S )Nz!Cache directory must not be None.)�AssertionError�super�__init__r )�selfr �� __class__r r r % s zSafeFileCache.__init__)�namer c C s4 t �|�}t|d d� �|g }tjj| jf|�� S )N� )r �encode�list�os�path�joinr )r r �hashed�partsr r r �_get_cache_path* s zSafeFileCache._get_cache_path)�keyr c C sR | � |�}t� �8 t|d��"}|�� W 5 Q R � W 5 Q R � S Q R X W 5 Q R X d S )N�rb)r% r �open�read)r r&