a
lj4 @ s d Z ddlZddlmZ ddlmZmZ ddlmZ ddl m
Z
ddlmZ ddl
mZmZ dd lmZ eed
ddZeed d
ddZG dd deZdS )zHTTP cache implementation.
N)contextmanager)IteratorOptional) BaseCache) FileCache)Response)adjacent_tmp_filereplace)
ensure_dir)responsereturnc C s t | ddS )NZ
from_cacheF)getattr)r r ?/usr/lib/python3.9/site-packages/pip/_internal/network/cache.py
is_from_cache s r )r c c s" z
dV W n t y Y n0 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 sn e Zd ZdZedd fddZeedddZeee d d
dZ eeddd
dZ
edd ddZ ZS )
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 usJ dt || _d S )Nz!Cache directory must not be None.)super__init__r )selfr __class__r r r % s
zSafeFileCache.__init__)namer c C s6 t |}t|d d |g }tjj| jg|R S )N )r encodelistospathjoinr )r r Zhashedpartsr r r _get_cache_path* s
zSafeFileCache._get_cache_path)keyr c C st | |}t P t|d&}| W d W d S 1 sH0 Y W d n1 sf0 Y d S )Nrb)r" r openread)r r# r fr r r get2 s
zSafeFileCache.get)r# valuer c C s | |}t ^ ttj| t|}|| W d n1 sJ0 Y t|j | W d n1 st0 Y d S N)
r" r r
r r dirnamer writer r )r r# r) r r' r r r set8 s
(zSafeFileCache.setc C s> | |}t t| W d n1 s00 Y d S r* )r" r r remove)r r# r r r r deleteB s
zSafeFileCache.delete)
__name__
__module____qualname____doc__strr r" r bytesr( r- r/
__classcell__r r r r r s
r )r3 r
contextlibr typingr r Zpip._vendor.cachecontrol.cacher Zpip._vendor.cachecontrol.cachesr Zpip._vendor.requests.modelsr Zpip._internal.utils.filesystemr r Zpip._internal.utils.miscr
boolr r r r r r r