U ��.e�5 � @ s� d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m Z ddlmZ e� e�Ze�d�Zd d � ZG dd� de�ZdS ) z7 The httplib2 algorithms ported for use with requests. � N)�parsedate_tz)�CaseInsensitiveDict� )� DictCache)� Serializerz9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?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 �G/usr/lib/python3.8/site-packages/pip/_vendor/cachecontrol/controller.py� parse_uri s r c @ s\ e Zd ZdZddd�Zedd� �Zedd � �Zd d� Zdd � Z dd� Z ddd�Zdd� ZdS )�CacheControllerz9An interface to see if request should cached or not. NTc C s, |pt � | _|| _|pt� | _|p$d| _d S )N)�� �� i, �- )r �cache�cache_etagsr � serializer�cacheable_status_codes)�selfr r r �status_codesr r r �__init__" s zCacheController.__init__c C sh t |�\}}}}}|r|s&td| ��|�� }|�� }|s>d}|rPd�||g�pR|}|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 ZschemeZ authority�pathZqueryZfragmentZrequest_uriZ defrag_urir r r �_urlnorm* s zCacheController._urlnormc C s | � |�S �N)r$ )r" r r r r � cache_url> s zCacheController.cache_urlc C s( t dft dft dfddddddddt dfd�}|�d|�dd��}i }|�d�D ]�}|�� s^qP|�d d �}|d �� }z|| \}} W n$ tk r� t�d|� Y qPY nX |r�| s�d ||<