a Re/ @ s* d Z ddlZddlmZmZmZmZmZ ddl m Z mZ ddlm Z mZ ddlmZ ddlmZ ddlmZmZmZmZmZ dd lmZ eeZeeeef ZzddlaW nL e y daY n8 e!y Z" z e#d ee" daW Y dZ"["n dZ"["0 0 ee ee ee ddd Z$G dd de Z%dS )zNetwork Authentication Helpers Contains interface (MultiDomainBasicAuth) and associated glue code for providing credentials in the context of network requests. N)AnyDictListOptionalTuple)AuthBase HTTPBasicAuth)RequestResponse)get_netrc_auth) getLogger)ask ask_inputask_passwordremove_auth_from_urlsplit_auth_netloc_from_url)AuthInfo*Keyring is skipped due to an exception: %s)urlusernamereturnc C s | rt sdS z~z t j}W n ty* Y n40 td| || |}|durX|j|jfW S W dS |rtd| t | |}|r||fW S W n8 ty } z t dt | da W Y d}~n d}~0 0 dS )z3Return the tuple auth for a given url from keyring.Nz'Getting credentials from keyring for %sz$Getting password from keyring for %sr )keyringget_credentialAttributeErrorloggerdebugr passwordget_password Exceptionwarningstr)r r r credr exc r# /builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/network/auth.pyget_keyring_auth( s0 r% c @ s e Zd Zd eeee ddddZeee dddZd!eeee d ddZ eeeee ee f d ddZe e dddZeeee ee ef dddZedddZeeedddZeeddddZeeddddZdS )"MultiDomainBasicAuthTN) prompting index_urlsr c C s || _ || _i | _d | _d S )N)r' r( passwords_credentials_to_save)selfr' r( r# r# r$ __init__J s zMultiDomainBasicAuth.__init__)r r c C sB |r | j sdS | j D ](}t|dd }||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+ r uprefixr# r# r$ _get_index_urlW s z#MultiDomainBasicAuth._get_index_urlF)original_urlallow_netrc allow_keyringr c C s t |\}}}|\}}|dur6|dur6td| |S | |} | rft | } | rf| \} }}td| | r|d dur|\}}|dur|durtd| |S |rt|} | rtd| | S |rt| |pt||}|rtd| |S ||fS )z2Find and return credentials for the specified URL.NzFound credentials in url for %szFound index url %sr z%Found credentials in index url for %sz!Found credentials in netrc for %sz#Found credentials in keyring for %s)r r r r2 r r% )r+ r3 r4 r5 r netlocurl_user_passwordr r index_url index_info_index_url_user_password netrc_authkr_authr# r# r$ _get_new_credentialsm s> z)MultiDomainBasicAuth._get_new_credentials)r3 r c C s t |\}}}| |\}}|du s,|du r^|| jv r^| j| \}}|du sT||kr^|| }}|dusn|dur|ptd}|p|d}||f| j|<