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" )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 Ú