u- d Z ddlZddlmZ ddlmZmZ ddlmZ ddl m Z ddlmZ ddl mZmZ dd lmZ d edefdZeded fd Z G d de ZdS )zHTTP cache implementation. N)contextmanager)IteratorOptional) BaseCache) FileCache)Response)adjacent_tmp_filereplace) ensure_dirresponsereturnc $ t | dd S )N from_cacheF)getattr)r s /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el9.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/network/cache.py is_from_cacher s 8\5111 c # 6 K dV dS # t $ r Y dS w xY w)zvIf we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. N)OSError r r suppressed_cache_errorsr s: s c | e Zd ZdZdeddf fdZdedefdZdedee fd Z ded eddfdZ deddfdZ xZS ) SafeFileCachezw A file based cache which is safe to use even when the target directory may not be accessible or writable. directoryr Nc n | J d t || _ d S )Nz!Cache directory must not be None.)super__init__r )selfr __class__s r r zSafeFileCache.__init__% s9 $$&I$$$ "r namec t j | }t |d d |gz }t j j | j g|R S )N )r encodelistospathjoinr )r r hashedpartss r _get_cache_pathzSafeFileCache._get_cache_path* sL !$''VBQBZ F8+w|DN3U3333r keyc | | }t 5 t |d 5 }| cd d d cd d d S # 1 swxY w Y d d d d S # 1 swxY w Y d S )Nrb)r* r openread)r r+ r&