관리-도구
편집 파일: cache.cpython-36.pyc
3 �Re � @ s� d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z ddl mZmZ ddl mZ dd lmZ erxdd lmZmZ dd� Zed d� �ZG dd� de�ZdS )zHTTP cache implementation. � N)�contextmanager)� BaseCache)� FileCache)�Response)�adjacent_tmp_file�replace)� ensure_dir)�MYPY_CHECK_RUNNING)�Optional�Iteratorc C s t | dd�S )N� from_cacheF)�getattr)�response� r ��/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/network/cache.py� is_from_cache s r c c s( y dV W n t tfk 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)�OSError�IOErrorr r r r �suppressed_cache_errors s r c s@ e Zd ZdZ� fdd�Zdd� Zdd� Zdd � Zd d� Z� Z S )� SafeFileCachezw A file based cache which is safe to use even when the target directory may not be accessible or writable. c s( |d k st d��tt| �j� || _d S )Nz!Cache directory must not be None.)�AssertionError�superr �__init__� directory)�selfr )� __class__r r r * s zSafeFileCache.__init__c C s4 t j|�}t|d d� �|g }tjj| jf|�� S )N� )r �encode�list�os�path�joinr )r �name�hashed�partsr r r �_get_cache_path0 s zSafeFileCache._get_cache_pathc C s: | j |�}t� � t|d�� }|j� S Q R X W d Q R X d S )N�rb)r% r �open�read)r �keyr �fr r r �get9 s zSafeFileCache.getc C sZ | j |�}t� �@ ttjj|�� t|��}|j|� W d Q R X t|j |� W d Q R X d S )N) r% r r r r �dirnamer �writer r"