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&