U ��.eo+ � @ s d Z ddlZddlmZmZ ddlmZ ddlmZ ddl mZmZm Z mZmZ ddlmZ er�ddlmZ dd lmZmZmZ dd lmZ eeeef Ze�e�ZzddlZW nL e k r� dZY n6 e!k r� Z" ze�#dee"�� dZW 5 dZ"["X Y nX dd � Z$G dd� de�Z%dS )z�Network Authentication Helpers Contains interface (MultiDomainBasicAuth) and associated glue code for providing credentials in the context of network requests. � N)�AuthBase� HTTPBasicAuth)�get_netrc_auth)�parse)�ask� ask_input�ask_password�remove_auth_from_url�split_auth_netloc_from_url)�MYPY_CHECK_RUNNING)�Values)�Dict�Optional�Tuple)�AuthInfo�*Keyring is skipped due to an exception: %sc C s� | rt sdS z�z t j}W n tk r, Y n4X t�d| � || |�}|dk rZ|j|jfW S W dS |r�t�d| � t �| |�}|r�||fW S W n2 tk r� } zt� dt |�� W 5 d}~X Y nX dS )z3Return the tuple auth for a given url from keyring.Nz'Getting credentials from keyring for %sz$Getting password from keyring for %sr )�keyring�get_credential�AttributeError�logger�debug�username�passwordZget_password� Exception�warning�str)�urlr r Zcredr �exc� r �>/usr/lib/python3.8/site-packages/pip/_internal/network/auth.py�get_keyring_auth. s, �r c @ s` e Zd Zddd�Zdd� Zddd�Zd d � Zdd� Zd d� Zdd� Z dd� Z dd� Zdd� ZdS )�MultiDomainBasicAuthTNc C s || _ || _i | _d | _d S )N)� prompting� index_urls� passwords�_credentials_to_save)�selfr" r# r r r �__init__M s zMultiDomainBasicAuth.__init__c C sB |r | j sdS | j D ](}t|��d�d }|�|�r| S qdS )a� Return the original index URL matching the requested URL. Cached or dynamically generated credentials may work against the original index URL rather than just the netloc. The provided url should have had its username and password removed already. If the original index url had credentials then they will be included in the return value. Returns None if no matching index was found, or if --no-index was specified by the user. N�/)r# r �rstrip� startswith)r&