a
    <Bìjº  ã                   @  sÈ   d dl mZ d dlZd dlZd dlZd dlmZmZmZm	Z	 d dl
mZ d dlmZ d dlmZmZ d dlmZ er´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 G dd„ deƒZdS )é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚ
CollectionÚMapping)ÚHTTPAdapter)Ú	DictCache)ÚPERMANENT_REDIRECT_STATUSESÚCacheController)ÚCallbackFileWrapper)ÚPreparedRequestÚResponse)ÚHTTPResponse)Ú	BaseCache)ÚBaseHeuristic)Ú
Serializerc                      sŒ   e Zd Zh d£Zd dddddd	d
d
ddœ	‡ fdd„Zd!ddddddd	ddœ‡ fdd„Zd"dddd	ddœ‡ fdd„Zddœ‡ fdd„Z‡  ZS )#ÚCacheControlAdapter>   ÚDELETEÚPUTÚPATCHNTzBaseCache | NoneÚboolztype[CacheController] | NonezSerializer | NonezBaseHeuristic | NonezCollection[str] | Noner   ÚNone)	ÚcacheÚcache_etagsÚcontroller_classÚ
serializerÚ	heuristicÚcacheable_methodsÚargsÚkwÚreturnc           
        sT   t ƒ j|i |¤Ž |d u r tƒ n|| _|| _|p2d| _|p<t}	|	| j||d�| _d S )N)ÚGET)r   r   )ÚsuperÚ__init__r   r   r   r   r
   Ú
controller)
Úselfr   r   r   r   r   r   r   r   Úcontroller_factory©Ú	__class__© ú_/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/adapter.pyr#      s    
ÿzCacheControlAdapter.__init__Fr   z7None | float | tuple[float, float] | tuple[float, None]z
bool | strz4None | bytes | str | tuple[bytes | str, bytes | str]zMapping[str, str] | Noner   )ÚrequestÚstreamÚtimeoutÚverifyÚcertÚproxiesr   r    c                   s€   |p| j }|j|v rfz| j |¡}	W n tjy<   d}	Y n0 |	rR| j||	dd�S |j | j 	|¡¡ t
ƒ  ||||||¡}
|
S )z”
        Send a request. Use the request information to see if it
        exists in the cache and cache the response if we need to and can.
        NT)Ú
from_cache)r   Úmethodr$   Úcached_requestÚzlibÚerrorÚbuild_responseÚheadersÚupdateÚconditional_headersr"   Úsend)r%   r+   r,   r-   r.   r/   r0   r   Ú	cacheableÚcached_responseÚrespr'   r)   r*   r:   2   s    


zCacheControlAdapter.sendr   )r+   Úresponser1   r   r    c           
   	     s6  |p| j }|sÞ|j|v rÞ| jr*| j |¡}|jdkrh| j ||¡}||urNd}|jdd� | ¡  |}nvt	|jƒt
v r†| j ||¡ nXt|jt | jj|t |¡¡ƒ|_|jrÞ|jj‰ dddœ‡ fdd	„}t |t |¡¡|_tƒ  ||¡}|j| jv �r,|j�r,|jd
u�sJ ‚| j |j¡}	| j |	¡ ||_|S )z¥
        Build a response by making a request or using the cache.

        This will end up calling send and returning a potentially
        cached response
        i0  TF)Údecode_contentz#weakref.ReferenceType[HTTPResponse]r   )Ú	weak_selfr    c                   s2   | ƒ }|d u rd S ˆ |ƒ |j dkr.|j ¡  d S )Nr   )Ú
chunk_leftÚ_fpÚ_close)r@   r%   ©Úsuper_update_chunk_lengthr)   r*   Ú_update_chunk_length‰   s    
z@CacheControlAdapter.build_response.<locals>._update_chunk_lengthN)r   r2   r   ÚapplyÚstatusr$   Úupdate_cached_responseÚreadÚrelease_connÚintr	   Úcache_responser   rB   Ú	functoolsÚpartialÚweakrefÚrefÚchunkedr(   rF   r"   r6   Úinvalidating_methodsÚokÚurlÚ	cache_urlr   Údeleter1   )
r%   r+   r>   r1   r   r;   r<   rF   r=   rV   r'   rD   r*   r6   P   sD    

ÿÿþ
ÿz"CacheControlAdapter.build_response)r    c                   s   | j  ¡  tƒ  ¡  d S )N)r   Úcloser"   )r%   r'   r)   r*   rX   ¥   s    
zCacheControlAdapter.close)NTNNNN)FNTNNN)FN)	Ú__name__Ú
__module__Ú__qualname__rS   r#   r:   r6   rX   Ú__classcell__r)   r)   r'   r*   r      s&         ù$      ø""  ûUr   )Ú
__future__r   rN   rP   r4   Útypingr   r   r   r   Zpip._vendor.requests.adaptersr   Zpip._vendor.cachecontrol.cacher   Z#pip._vendor.cachecontrol.controllerr	   r
   Z$pip._vendor.cachecontrol.filewrapperr   Zpip._vendor.requestsr   r   Zpip._vendor.urllib3r   r   Z#pip._vendor.cachecontrol.heuristicsr   Z"pip._vendor.cachecontrol.serializer   r   r)   r)   r)   r*   Ú<module>   s   