o ai/ @ s. d Z ddlZddlmZmZmZmZmZ ddl m Z mZ ddlm Z mZ ddlmZ ddlmZ ddlmZmZmZmZmZ dd lmZ eeZeeeef ZzddlaW n& e y` daY n e!y{ Z" ze#d ee" daW Y dZ"["ndZ"["ww dee dee d ee fddZ$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: %surlusernamereturnc C s | rt sdS zCzt j}W n ty Y nw td| || |}|dur,|j|jfW S W dS |rDtd| t | |}|rG||fW S W dS W dS tyf } zt dt | da W Y d}~dS d}~ww )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-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/network/auth.pyget_keyring_auth( s> r% c @ s e Zd Z d#dedeee ddfddZdedee fd d Z d$ded edede fddZ dedeeee ee f fddZde de fddZdedeee ee ef fddZdefddZdededefddZdededdfdd Zdededdfd!d"ZdS )%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 c C sB |r| j sdS | j D ]}t|dd }||r| S q dS )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_urlForiginal_urlallow_netrc allow_keyringc C s t |\}}}|\}}|dur|durtd| |S | |} | r3t | } | r3| \} }}td| | rO|d durO|\}}|durO|durOtd| |S |r_t|} | r_td| | S |rut| |pjt||}|rutd| |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_credentialsc C s t |\}}}| |\}}|du s|du r/|| jv r/| j| \}}|du s*||kr/||}}|dus7|durF|p:d}|p>d}||f| j|<