
    $Ȃi                        S SK Jr  S SKrS SKrS SKJr  S SKJrJrJ	r	  S SK
Jr  S SKJrJr  S SKJr  \(       a  S SKJr  S S	KJr  SS
 jr " S S5      r " S S\\5      r " S S\\5      rSS jrg)    )annotationsN)dedent)IOTYPE_CHECKINGUnion)Path)	BaseCacheSeparateBodyBaseCache)CacheController)datetime)BaseFileLockc                   [         R                  nU[         R                  [         R                  -  -  n[	        [         S5      (       a  U[         R
                  -  n[	        [         S5      (       a  U[         R                  -  n [         R                  " U 5        [         R                  " XU5      n [         R                  " US5      $ ! [         a     N;f = f!   [         R                  " U5        e = f)N
O_NOFOLLOWO_BINARYwb)osO_WRONLYO_CREATO_EXCLhasattrr   r   removeOSErroropenfdopenclose)filenamefmodeflagsfds       [D:\sksbv-state-backend\venv\Lib\site-packages\pip/_vendor/cachecontrol/caches/file_cache.py_secure_open_writer!      s    KKE 
RZZ"))##E r<   r:
		( 
%	(ByyT""  
s   C 4C 
CCC4c                      \ rS rSrSr    S           SS jjr\SS j5       rSS jrSS jr	 S       SS jjr
SS	 jrSS
 jrSrg)_FileCacheMixin>   z2Shared implementation for both FileCache variants.Nc                     Uc  SSK Jn  UnXl        X l        X0l        X@l        XPl        g ! [         a    [        S5      n[        U5      ef = f)Nr   )FileLockz
            NOTE: In order to use the FileCache you must have
            filelock installed. You can install it via pip:
              pip install cachecontrol[filecache]
            )	filelockr&   ImportErrorr   	directoryforeverfilemodedirmode
lock_class)selfr)   r*   r+   r,   r-   r&   notices           r    __init___FileCacheMixin.__init__A   s]    	&!-%
 # $  	&F f%%	&s	   , !Ac                f    [         R                  " U R                  5       5      R                  5       $ N)hashlibsha224encode	hexdigest)xs    r    r6   _FileCacheMixin.encode^   s     ~~ahhj)3355    c                    U R                  U5      n[        US S 5      U/-   n[        R                  R                  " U R
                  /UQ76 $ )N   )r6   listr   pathjoinr)   )r.   namehashedpartss       r    _fn_FileCacheMixin._fnb   sE     T"VBQZ F8+ww||DNN3U33r:   c                    U R                  U5      n [        US5       nUR                  5       sS S S 5        $ ! , (       d  f       g = f! [         a     g f = f)Nrb)rC   r   readFileNotFoundError)r.   keyr@   fhs       r    get_FileCacheMixin.geti   sH    xx}	dD!Rwwy "!! ! 		s+   A
 9	A
 
AA
 A
 

AAc                H    U R                  U5      nU R                  XB5        g r3   rC   _write)r.   rI   valueexpiresr@   s        r    set_FileCacheMixin.setr   s     xx}D r:   c                ~    [         R                  " [         R                  R                  U5      U R                  5        U R                  US-   5         [        XR                  5       nUR                  U5        SSS5        SSS5        g! [
         a     NYf = f! , (       d  f       N'= f! , (       d  f       g= f)z*
Safely write the data to the given path.
z.lockN)
r   makedirsr>   dirnamer,   r   r-   r!   r+   write)r.   r>   datarJ   s       r    rO   _FileCacheMixin._writex   s    
	KK-t||< __TG^,#D--8B 9 -,  		
 98 -,s5   >B B.*B<B.
BB
B+	'B..
B<c                    U R                  U5      U-   nU R                  (       d   [        R                  " U5        g g ! [         a     g f = fr3   )rC   r*   r   r   rH   )r.   rI   suffixr@   s       r    _delete_FileCacheMixin._delete   sD    xx}v%||		$  % s   ? 
AA)r)   r,   r+   r*   r-   )Fi  i  N)r)   z
str | Pathr*   boolr+   intr,   r_   r-   ztype[BaseFileLock] | NonereturnNone)r8   strr`   rb   )r@   rb   r`   rb   )rI   rb   r`   zbytes | Noner3   )rI   rb   rP   bytesrQ   zint | datetime | Noner`   ra   )r>   rb   rX   rc   r`   ra   )rI   rb   r[   rb   r`   ra   )__name__
__module____qualname____firstlineno____doc__r0   staticmethodr6   rC   rK   rR   rO   r\   __static_attributes__ r:   r    r#   r#   >   s    <
 04%% % 	%
 % .% 
%: 6 64 HL!!$!/D!	!r:   r#   c                  "    \ rS rSrSrSS jrSrg)	FileCache   zW
Traditional FileCache: body is stored in memory, so not suitable for large
downloads.
c                (    U R                  US5        g )N r\   r.   rI   s     r    deleteFileCache.delete   s    S"r:   rk   NrI   rb   r`   ra   )rd   re   rf   rg   rh   rs   rj   rk   r:   r    rm   rm      s    
r:   rm   c                  6    \ rS rSrSrSS jrS	S jrS
S jrSrg)SeparateBodyFileCache   z\
Memory-efficient FileCache: body is stored in a separate file, reducing
peak memory usage.
c                d    U R                  U5      S-   n [        US5      $ ! [         a     g f = f)N.bodyrF   )rC   r   rH   )r.   rI   r@   s      r    get_bodySeparateBodyFileCache.get_body   s8    xx}w&	d##  		s   " 
//c                N    U R                  U5      S-   nU R                  X25        g )Nrz   rN   )r.   rI   bodyr@   s       r    set_bodySeparateBodyFileCache.set_body   s     xx}w&Dr:   c                L    U R                  US5        U R                  US5        g )Nrp   rz   rq   rr   s     r    rs   SeparateBodyFileCache.delete   s    S"S'"r:   rk   N)rI   rb   r`   zIO[bytes] | None)rI   rb   r~   rc   r`   ra   ru   )	rd   re   rf   rg   rh   r{   r   rs   rj   rk   r:   r    rw   rw      s    
 #r:   rw   c                P    [         R                  " U 5      nUR                  U5      $ )zTReturn the file cache path based on the URL.

This does not ensure the file exists!
)r   	cache_urlrC   )url	filecacherI   s      r    url_to_file_pathr      s#    
 
#
#C
(C==r:   )r   rb   r   r_   r`   z	IO[bytes])r   rb   r   rm   r`   rb   )
__future__r   r4   r   textwrapr   typingr   r   r   pathlibr   pip._vendor.cachecontrol.cacher	   r
   #pip._vendor.cachecontrol.controllerr   r   r'   r   r!   r#   rm   rw   r   rk   r:   r    <module>r      s`    #  	  + +  K ?!%&RO Od #O-B #,r:   