U ʗRea @ s d Z ddlZddlmZ ddlmZmZ ddlmZ ddl m Z ddlmZ ddl mZmZ dd lmZ eed ddZeed dddZG dd deZdS )zHTTP cache implementation. N)contextmanager) GeneratorOptional) BaseCache) FileCache)Response)adjacent_tmp_filereplace) ensure_dir)responsereturnc C s t | ddS )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 fddZeedddZeee d d dZ deeee ddd dZedd ddZ 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 dt || _d S )Nz!Cache directory must not be None.)AssertionErrorsuper__init__r )selfr __class__r r r % s zSafeFileCache.__init__)namer c C s4 t |}t|d d |g }tjj| jf| S )N )r encodelistospathjoinr )r r hashedpartsr 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 )Nrb)r% r openread)r r&