File: //lib/python3/dist-packages/pip/_vendor/cachecontrol/__pycache__/controller.cpython-310.pyc
o
@%Ne = � @ s� d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m
Z
ddlmZ e�
e�Ze�d�Zd Zd
d� ZG dd
� d
e�ZdS )z7
The httplib2 algorithms ported for use with requests.
� N)�parsedate_tz)�CaseInsensitiveDict� )� DictCache)�
Serializerz9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)�- �4 c C s0 t �| ��� }|d |d |d |d |d fS )z�Parses a URI using the regex given in Appendix B of RFC 3986.
(scheme, authority, path, query, fragment) = parse_uri(uri)
r � � � � )�URI�match�groups)�urir � r �E/usr/lib/python3/dist-packages/pip/_vendor/cachecontrol/controller.py� parse_uri s "r c @ s^ e Zd ZdZ ddd�Zedd� �Zedd � �Zd
d� Zdd
� Z dd� Z
ddd�Zdd� ZdS )�CacheControllerz9An interface to see if request should cached or not.
NTc C s4 |d u rt � n|| _|| _|pt� | _|pd| _d S )N)�� �� i, r r )r �cache�cache_etagsr �
serializer�cacheable_status_codes)�selfr r r �status_codesr r r �__init__( s zCacheController.__init__c C sh t |�\}}}}}|r
|std| ��|�� }|�� }|sd}|r(d�||g�p)|}|d | | }|S )z4Normalize the URL to create a safe key for the cachez(Only absolute URIs are allowed. uri = %s�/�?z://)r � Exception�lower�join) �clsr �scheme� authority�path�query�fragment�request_uri�
defrag_urir r r �_urlnorm0 s zCacheController._urlnormc C s
| � |�S �N)r+ )r# r r r r � cache_urlD s
zCacheController.cache_urlc
C s t dft dft dfddddddddt dfd�}|�d|�dd��}i }|�d�D ]c}|�� s/q(|�d d
�}|d �� }z|| \}} W n tyR t�d|� Y q(w |rW| s[d ||<