OwlCyberSecurity - MANAGER
Edit File: cache.cpython-38.pyc
U ��]Z � @ s� d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z ddl mZmZ ddl mZ dd lmZ ertdd lmZ dd� Zed d� �ZG dd� de�ZdS )zHTTP cache implementation. � N)�contextmanager)� BaseCache)� FileCache)�Response)�adjacent_tmp_file�replace)� ensure_dir)�MYPY_CHECK_RUNNING)�Optionalc C s t | dd�S )NZ from_cacheF)�getattr)Zresponse� r �=/usr/lib/python3/dist-packages/pip/_internal/network/cache.py� is_from_cache s r c c s( z 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| ��� || _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 �|�}t|d d� �|g }tjj| jf|�� S )N� )r �encode�list�os�path�joinr )r �nameZhashed�partsr r r �_get_cache_path2 s zSafeFileCache._get_cache_pathc 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"