a
    sh{                     @  s  d dl m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
 d dlmZ d dlmZ d dlmZ d d	lmZmZ d d
lmZ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  d dl!m"Z" d dl#m$Z$ d dl%m&Z& e'e(Z)G dd deZ*dS )    )annotationsN)Iterable)Values)AnyCallable)Version)
cmdoptions)IndexGroupCommand)ERRORSUCCESS)get_installed_distributionprint_dist_installation_info)CommandErrorDistributionNotFoundPipError)LinkCollector)PackageFinder)SelectionPreferences)TargetPython)
PipSession)write_outputc                   @  sp   e Zd ZdZdZdZddddZddd	d
ZddddddZdddddddddZ	ddddddZ
dS )IndexCommandz=
    Inspect information available from package indexes.
    Tz&
        %prog versions <package>
    None)returnc                 C  s   t | j | jt   | jt   | jt   | jt   | jt   t 	t j
| j}| jd| | jd| j d S )Nr   )r   add_target_python_optionscmd_opts
add_optionignore_requires_pythonprejson	no_binaryonly_binarymake_option_groupindex_groupparserinsert_option_group)self
index_opts r(   X/var/www/html/assistant/venv/lib/python3.9/site-packages/pip/_internal/commands/index.pyadd_options'   s    zIndexCommand.add_optionsz.dict[str, Callable[[Values, list[str]], None]]c                 C  s
   d| j iS )Nversions)get_available_package_versions)r&   r(   r(   r)   handler_map8   s    zIndexCommand.handler_mapr   z	list[str]int)optionsargsr   c              
   C  s   |   }|r|d |vr2tddt| tS |d }z|| ||dd   W n8 ty } z t|jd  tW  Y d }~S d }~0 0 tS )Nr   zNeed an action (%s) to perform.,    )	r-   loggererrorjoinsortedr
   r   r0   r   )r&   r/   r0   r-   actioner(   r(   r)   run=   s    zIndexCommand.runNr   zTargetPython | Nonezbool | Noner   )r/   sessiontarget_pythonr   r   c                 C  s.   t j||d}td|j|d}tj|||dS )zK
        Create a package finder appropriate to the index command.
        )r/   F)allow_yankedallow_all_prereleasesr   )link_collectorselection_prefsr;   )r   creater   r   r   )r&   r/   r:   r;   r   r>   r?   r(   r(   r)   _build_package_finderS   s    
z"IndexCommand._build_package_finderz	list[Any]c                 C  s<  t |dkrtdt|}|d }| |}| j||||jd}dd ||D }|jsndd |D }t	|}|st
d| d	d
 t|ddD }|d }	W d    n1 s0    Y  t|}
|jr|||	d}|
d urt|
j|d< tt| n2t| d|	 d tdd| t|	|
 d S )Nr2   z(You need to specify exactly one argumentr   )r/   r:   r;   r   c                 s  s   | ]}|j V  qd S N)version).0	candidater(   r(   r)   	<genexpr>{   s   z>IndexCommand.get_available_package_versions.<locals>.<genexpr>c                 s  s   | ]}|j s|V  qd S rB   )is_prerelease)rD   rC   r(   r(   r)   rF      s   z#No matching distribution found for c                 S  s   g | ]}t |qS r(   )str)rD   verr(   r(   r)   
<listcomp>       z?IndexCommand.get_available_package_versions.<locals>.<listcomp>T)reverse)namer+   latestinstalled_versionz ()zAvailable versions: {}r1   )lenr   r   make_target_python_build_sessionrA   r   find_all_candidatesr   setr   r6   r   r   rH   rC   r   dumpsformatr5   r   )r&   r/   r0   r;   queryr:   finderr+   Zformatted_versionsrN   distZstructured_outputr(   r(   r)   r,   l   sJ    
&z+IndexCommand.get_available_package_versions)NN)__name__
__module____qualname____doc__ignore_require_venvusager*   r-   r9   rA   r,   r(   r(   r(   r)   r      s     r   )+
__future__r   r   loggingcollections.abcr   optparser   typingr   r   Zpip._vendor.packaging.versionr   Zpip._internal.clir   pip._internal.cli.req_commandr	   pip._internal.cli.status_codesr
   r   Zpip._internal.commands.searchr   r   pip._internal.exceptionsr   r   r   pip._internal.index.collectorr   "pip._internal.index.package_finderr   $pip._internal.models.selection_prefsr   "pip._internal.models.target_pythonr   pip._internal.network.sessionr   pip._internal.utils.miscr   	getLoggerr[   r3   r   r(   r(   r(   r)   <module>   s&   
