o
    j                     @  s  d Z ddlm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 ddlmZ ddlmZ dd	lmZ dd
lmZ erXddlmZ ddlmZ ddlmZ ddlmZ eeZe	d"ddZG dd deZ d#ddZ!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.
    )annotationsN)Iterator)	lru_cache)Values)TYPE_CHECKING)certifi)Command)CommandContextMixIn)
SSLContext)NormalizedName
PipSession)UpgradePromptreturnSSLContext | Nonec                  C  sz   zdd l } W n ty   td Y d S w zddlm} W n ty-   td Y d S w || j}|t	
  |S )Nr   z1Disabling truststore since ssl support is missing)
truststorez5Disabling truststore because platform isn't supported)sslImportErrorloggerwarningpip._vendorr   r
   PROTOCOL_TLS_CLIENTload_verify_locationsr   where)r   r   ctx r   `/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/pip/_internal/cli/index_command.py_create_truststore_ssl_context#   s   

r   c                      sJ   e Zd ZdZd fddZedd	d
ZdddZ		ddddZ  Z	S )SessionCommandMixinzE
    A class mixin for command classes needing _build_session().
    r   Nonec                   s   t    d | _d S )N)super__init___session)self	__class__r   r   r!   ;   s   

zSessionCommandMixin.__init__optionsr   list[str] | Nonec                 C  sL   g }t |ddst |dd}|r|| t |dd}|r"|| |p%d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_sessionM   s   
z'SessionCommandMixin.get_default_sessionNretries
int | Nonetimeoutc                 C  s   ddl m} |j}|rtj|sJ d|jvrt }nd }||r(tj|dnd |d ur/|n|j	|j
|j| ||d}|jrD|j|_|jrK|j|_|jsP|rZ|d urV|n|j|_|jrl|j|jd|_d|_|j|_|j |j_|j|j_|S )Nr   r   zlegacy-certszhttp-v2)cacher6   resume_retriestrusted_hostsr/   ssl_context)httphttpsF)pip._internal.network.sessionr   	cache_dirospathisabsdeprecated_features_enabledr   joinr6   r:   r;   r2   certverifyclient_certr8   proxyproxies	trust_envZ	pip_proxyno_inputauth	promptingZkeyring_provider)r#   r&   r6   r8   r   r@   r<   sessionr   r   r   r4   W   s:   



z"SessionCommandMixin._build_session)r   r   )r&   r   r   r'   )r&   r   r   r   )NN)r&   r   r6   r7   r8   r7   r   r   )
__name__
__module____qualname____doc__r!   classmethodr2   r5   r4   __classcell__r   r   r$   r   r   6   s    
r   rO   r   r&   r   UpgradePrompt | Nonec                 C  s   ddl m} || |S )Nr   )pip_self_version_check_fetch)!pip._internal.self_outdated_checkrW   )rO   r&   rW   r   r   r   _pip_self_version_check_fetch   s   
rY   upgrade_promptr   c                 C  s   ddl m} ||  d S )Nr   )pip_self_version_check_emit)rX   r[   )rZ   r[   r   r   r   _pip_self_version_check_emit   s   r\   c                   @  s*   e Zd ZdZddd	Zej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.
    r&   r   package_namer   r   boolc                 C  s.   |j r|j |}|du rdS |du rdS dS )zM
        Determine if pre-releases should be excluded for a package.
        TF)Zrelease_controlZallows_prereleases)r#   r&   r^   allow_prereleasesr   r   r   should_exclude_prerelease   s   z+IndexGroupCommand.should_exclude_prereleaseargs	list[str]Iterator[None]c                 c  s   t |dsJ |js|jrdV  dS d}z%| j|dtd|jd}| t||}W d   n1 s4w   Y  W n tyO   t	d tj
ddd	 Y nw z"dV  W zt| W dS  tyr   t	d tj
ddd	 Y dS w zt| W w  ty   t	d tj
ddd	 Y w w )
z
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        r(   Nr      )r6   r8   z6There was an error checking the latest version of pip.zSee below for errorT)exc_info)hasattrdisable_pip_version_checkr(   r4   minr8   rY   	Exceptionr   r   debugr\   )r#   r&   rb   rZ   rO   r   r   r   pip_version_check   sD   



z#IndexGroupCommand.pip_version_checkN)r&   r   r^   r   r   r_   )r&   r   rb   rc   r   rd   )rP   rQ   rR   rS   ra   
contextlibcontextmanagerrl   r   r   r   r   r]      s
    
r]   )r   r   )rO   r   r&   r   r   rV   )rZ   rV   r   r   )$rS   
__future__r   rm   loggingrA   collections.abcr   	functoolsr   optparser   typingr   r   r   pip._internal.cli.base_commandr   !pip._internal.cli.command_contextr	   r   r
   Zpip._vendor.packaging.utilsr   r?   r   rX   r   	getLoggerrP   r   r   r   rY   r\   r]   r   r   r   r   <module>   s0    

V
