
    *,ha                         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y)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    ]/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pip/_internal/network/cache.pyis_from_cacher      s    8\511    )NNNc               #   4   K   	 d y# t         $ r Y yw xY w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                 B    |J d       t         |           || _        y )Nz!Cache directory must not be None.)super__init__r   )selfr   	__class__s     r   r   zSafeFileCache.__init__%   s$    $I&II"r   namec                     t        j                  |      }t        |d d       |gz   }t        j                  j
                  | j                  g| S )N   )r   encodelistospathjoinr   )r   r    hashedpartss       r   _get_cache_pathzSafeFileCache._get_cache_path*   sG     !!$'VBQZ F8+ww||DNN3U33r   keyc                     | j                  |      }t               5  t        |d      5 }|j                         cd d d        cd d d        S # 1 sw Y   nxY w	 d d d        y # 1 sw Y   y xY w)Nrb)r*   r   openread)r   r+   r&   fs       r   getzSafeFileCache.get2   sk    ##C($& 	 dD!  Qvvx   	  	      	  	  	 s!   A"A	A"A	A""A+valueexpiresc                 B   | j                  |      }t               5  t        t        j                  j                  |             t        |      5 }|j                  |       d d d        t        j                  |       d d d        y # 1 sw Y   (xY w# 1 sw Y   y xY wN)
r*   r   r   r%   r&   dirnamer	   writer
   r    )r   r+   r2   r3   r&   r0   s         r   setzSafeFileCache.set8   s    ##C($& 	"rwwt,-"4( A AFFD!	" 	" 	" 	"s#   4BB	"B	B	BBc                     | j                  |      }t               5  t        j                  |       d d d        y # 1 sw Y   y xY wr5   )r*   r   r%   remove)r   r+   r&   s      r   deletezSafeFileCache.deleteB   s8    ##C($& 	IIdO	 	 	s	   ;Ar5   )__name__
__module____qualname____doc__strr   r*   r   bytesr1   intr8   r;   __classcell__)r   s   @r   r   r      s}    
## #$ #
4C 4C 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      sd    
 % & 4 5 0 E /2H 2 2 +;!<  &I &r   