
    ea                         d Z ddlZddlmZ ddlmZmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZmZ dd	lmZ d
edefdZeded         fd            Z G d de          ZdS )zHTTP cache implementation.
    N)contextmanager)	GeneratorOptional)	BaseCache)	FileCache)Response)adjacent_tmp_filereplace)
ensure_dirresponsereturnc                 $    t          | dd          S )N
from_cacheF)getattr)r   s    R/var/www/html/api/venv/lib/python3.11/site-packages/pip/_internal/network/cache.pyis_from_cacher      s    8\5111    )NNNc               #   6   K   	 dV  dS # t           $ r Y dS w xY w)zvIf we can't access the cache then we can just skip caching and process
    requests as if caching wasn't enabled.
    N)OSError r   r   suppressed_cache_errorsr      s:      
   s   
 
c            	            e Zd ZdZdeddf fdZdedefdZdedee         fd	Z	dded
edee
         ddfdZdeddfdZ xZS )SafeFileCachezw
    A file based cache which is safe to use even when the target directory may
    not be accessible or writable.
    	directoryr   Nc                 n    |
J d            t                                                       || _        d S )Nz!Cache directory must not be None.)super__init__r   )selfr   	__class__s     r   r   zSafeFileCache.__init__%   s9    $$&I$$$"r   namec                     t          j        |          }t          |d d                   |gz   }t          j        j        | j        g|R  S )N   )r   encodelistospathjoinr   )r   r    hashedpartss       r   _get_cache_pathzSafeFileCache._get_cache_path*   sL     !$''VBQBZ  F8+w|DN3U3333r   keyc                    |                      |          }t                      5  t          |d          5 }|                                cd d d            cd d d            S # 1 swxY w Y   	 d d d            d S # 1 swxY w Y   d S )Nrb)r*   r   openread)r   r+   r&   fs       r   getzSafeFileCache.get2   s   ##C(($&& 	  	 dD!!  Qvvxx             	  	  	  	  	  	  	  	                  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s4   A;A"	A;"A&	&A;)A&	*A;;A?A?valueexpiresc                 x   |                      |          }t                      5  t          t          j                            |                     t          |          5 }|                    |           d d d            n# 1 swxY w Y   t          |j	        |           d d d            d S # 1 swxY w Y   d S N)
r*   r   r   r%   r&   dirnamer	   writer
   r    )r   r+   r2   r3   r&   r0   s         r   setzSafeFileCache.set8   s$   ##C(($&& 	" 	"rwt,,---"4(( A               AFD!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s5   <B/ B6B/B	B/	B	
B//B36B3c                     |                      |          }t                      5  t          j        |           d d d            d S # 1 swxY w Y   d S r5   )r*   r   r%   remove)r   r+   r&   s      r   deletezSafeFileCache.deleteB   s    ##C(($&& 	 	IdOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AA
A
r5   )__name__
__module____qualname____doc__strr   r*   r   bytesr1   intr8   r;   __classcell__)r   s   @r   r   r      s         
## #$ # # # # # #
4C 4C 4 4 4 4 s  x        " "s "5 "8C= "D " " " "# $        r   r   )r?   r%   
contextlibr   typingr   r   pip._vendor.cachecontrol.cacher   pip._vendor.cachecontrol.cachesr   pip._vendor.requests.modelsr   pip._internal.utils.filesystemr	   r
   pip._internal.utils.miscr   boolr   r   r   r   r   r   <module>rL      s'    
			 % % % % % % & & & & & & & & 4 4 4 4 4 4 5 5 5 5 5 5 0 0 0 0 0 0 E E E E E E E E / / / / / /2H 2 2 2 2 2 +;!<    & & & & &I & & & & &r   