3
Re @ s d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z ddl
mZmZ ddl
mZ dd lmZ erxdd
lmZmZ dd Zed
d ZG dd deZdS )zHTTP cache implementation.
N)contextmanager) BaseCache) FileCache)Response)adjacent_tmp_filereplace)
ensure_dir)MYPY_CHECK_RUNNING)OptionalIteratorc C s t | ddS )N
from_cacheF)getattr)response r /builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el9.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)OSErrorIOErrorr r r r suppressed_cache_errors s
r c s@ e Zd ZdZ fddZdd 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 dtt| j || _d S )Nz!Cache directory must not be None.)AssertionErrorsuperr __init__ directory)selfr ) __class__r r r * s zSafeFileCache.__init__c C s4 t j|}t|d d |g }tjj| jf| S )N )r encodelistospathjoinr )r namehashedpartsr 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 )Nrb)r% r openread)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" )r r) valuer r* r r r set@ s
zSafeFileCache.setc C s* | j |}t tj| W d Q R X d S )N)r% r r remove)r r) r r r r deleteK s
zSafeFileCache.delete)
__name__
__module____qualname____doc__r r% r+ r/ r1
__classcell__r r )r r r $ s r )r5 r
contextlibr Zpip._vendor.cachecontrol.cacher pip._vendor.cachecontrol.cachesr Zpip._vendor.requests.modelsr pip._internal.utils.filesystemr r pip._internal.utils.miscr pip._internal.utils.typingr typingr
r r r r r r r r