U ʗRea@sdZddlZddlmZddlmZmZddlmZddl m Z ddl m Z ddl mZmZdd lmZe ed d d Zeed dddZGdddeZdS)zHTTP cache implementation. N)contextmanager) GeneratorOptional) BaseCache) FileCache)Response)adjacent_tmp_filereplace) ensure_dir)responsereturncCs 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_cachesr)NNN)r ccs$z dVWntk rYnXdS)zvIf we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. N)OSErrorrrrrsuppressed_cache_errorss rcsveZdZdZeddfdd ZeedddZeeed d d Z deeee dd d dZ edd 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 cs$|dk stdt||_dS)Nz!Cache directory must not be None.)AssertionErrorsuper__init__r)selfr __class__rrr%s zSafeFileCache.__init__)namer cCs4t|}t|dd|g}tjj|jf|S)N)rencodelistospathjoinr)rrhashedpartsrrr_get_cache_path*s zSafeFileCache._get_cache_path)keyr c CsR||}t8t|d"}|W5QRW5QRSQRXW5QRXdS)Nrb)r%ropenread)rr&r!frrrget2s  zSafeFileCache.get)r&valueexpiresr c CsZ||}t@ttj|t|}||W5QRXt|j |W5QRXdSN) r%rr r r!dirnamerwriter r)rr&r,r-r!r*rrrset8s   zSafeFileCache.setc Cs*||}tt|W5QRXdSr.)r%rr remove)rr&r!rrrdeleteBs zSafeFileCache.delete)N)__name__ __module__ __qualname____doc__strrr%rbytesr+intr1r3 __classcell__rrrrrs  r)r7r contextlibrtypingrrZpip._vendor.cachecontrol.cacherpip._vendor.cachecontrol.cachesrZpip._vendor.requests.modelsrpip._internal.utils.filesystemrr pip._internal.utils.miscr boolrrrrrrrs