a
    $lJhX                     @   s   d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZ e	rdd	lmZ dd
lmZ eeZeed dddZG dd deZdeddddZG dd deeZdS )a&  
Contains command classes which may interact with an index / the network.

Unlike its sister module, req_command, this module still uses lazy imports
so commands which don't always hit the network (e.g. list w/o --outdated or
--uptodate) don't need waste time importing PipSession and friends.
    N)	lru_cache)Values)TYPE_CHECKINGListOptional)certifi)Command)CommandContextMixIn)
SSLContext
PipSessionr
   returnc                  C   s   t jdk rtd d S zdd l} W n tyB   td Y d S 0 zddlm} W n tyr   td Y d S 0 |	| j
}|t  |S )N)   
   z7Disabling truststore because Python version isn't 3.10+r   z1Disabling truststore since ssl support is missing)
truststorez5Disabling truststore because platform isn't supported)sysversion_infologgerdebugsslImportErrorwarningpip._vendorr   r
   PROTOCOL_TLS_CLIENTload_verify_locationsr   where)r   r   ctx r   Q/var/www/shaz/venv/lib/python3.9/site-packages/pip/_internal/cli/index_command.py_create_truststore_ssl_context   s     



r    c                       sp   e Zd ZdZdd fddZeeeee	  dddZ
ed	dd
dZdeee ee d	dddZ  ZS )SessionCommandMixinzE
    A class mixin for command classes needing _build_session().
    Nr   c                    s   t    d | _d S )N)super__init___session)self	__class__r   r   r#   9   s    
zSessionCommandMixin.__init__optionsr   c                 C   sL   g }t |dds*t |dd}|r*|| t |dd}|rD|| |pJdS )z7Return a list of index urls from user-provided options.no_indexF	index_urlNextra_index_urls)getattrappendextend)clsr)   
index_urlsurlurlsr   r   r   _get_index_urls=   s    

z#SessionCommandMixin._get_index_urlsr   c                 C   s0   | j du r*| | || _ | j dus*J | j S )zGet a default-managed session.N)r$   enter_context_build_session)r%   r)   r   r   r   get_default_sessionK   s    
z'SessionCommandMixin.get_default_session)r)   retriestimeoutr   c                 C   s   ddl m} |j}|r&tj|s&J d|jvr8t }nd }||rPtj|dnd |d ur^|n|j	|j
| ||d}|jr|j|_|jr|j|_|js|r|d ur|n|j|_|jr|j|jd|_d|_|j|_|j |j_|j|j_|S )Nr   r   zlegacy-certszhttp-v2)cacher8   trusted_hostsr1   ssl_context)httphttpsF)pip._internal.network.sessionr   	cache_dirospathisabsdeprecated_features_enabledr    joinr8   r;   r4   certverifyclient_certr9   proxyproxies	trust_envZ	pip_proxyno_inputauth	promptingZkeyring_provider)r%   r)   r8   r9   r   r@   r<   sessionr   r   r   r6   U   s8    
	

z"SessionCommandMixin._build_session)NN)__name__
__module____qualname____doc__r#   classmethodr   r   r   strr4   r7   intr6   __classcell__r   r   r&   r   r!   4   s     r!   r   )rO   r)   r   c                 C   s   ddl m} || | d S )Nr   )pip_self_version_check)!pip._internal.self_outdated_checkrX   )rO   r)   checkr   r   r   _pip_self_version_check   s    r[   c                   @   s    e Zd ZdZeddddZdS )IndexGroupCommandz
    Abstract base class for commands with the index_group options.

    This also corresponds to the commands that permit the pip version check.
    Nr(   c                 C   s   t |dsJ |js|jrdS zJ| j|dtd|jd}| t|| W d   n1 s\0    Y  W n* ty   t	d tj
ddd	 Y n0 dS )
z
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        r*   Nr      )r8   r9   z6There was an error checking the latest version of pip.zSee below for errorT)exc_info)hasattrdisable_pip_version_checkr*   r6   minr9   r[   	Exceptionr   r   r   )r%   r)   rO   r   r   r   handle_pip_version_check   s    
,
z*IndexGroupCommand.handle_pip_version_check)rP   rQ   rR   rS   r   rc   r   r   r   r   r\      s   r\   )rS   loggingrA   r   	functoolsr   optparser   typingr   r   r   r   r   pip._internal.cli.base_commandr   !pip._internal.cli.command_contextr	   r   r
   r?   r   	getLoggerrP   r   r    r!   r[   r\   r   r   r   r   <module>   s$   
U