o
    Ëý°jñ  ã                   @   sî   d dl Z d dlmZ d dlmZmZmZmZmZ d dl	m
Z
m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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 )é    N)ÚValues)ÚAnyÚIterableÚListÚOptionalÚUnion)ÚLegacyVersionÚVersion)Ú
cmdoptions)ÚIndexGroupCommand)ÚERRORÚSUCCESS)Úprint_dist_installation_info)ÚCommandErrorÚDistributionNotFoundÚPipError)ÚLinkCollector)ÚPackageFinder)ÚSelectionPreferences)ÚTargetPython)Ú
PipSession)Úwrite_outputc                   @   s~   e Zd ZdZdZddd„Zdedee de	fd	d
„Z
		ddededee dee def
dd„Zdedee ddfdd„ZdS )ÚIndexCommandz=
    Inspect information available from package indexes.
    z&
        %prog versions <package>
    ÚreturnNc                 C   s~   t  | j¡ | 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Ú	no_binaryÚonly_binaryÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚ
index_opts© r'   ú�/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_internal/commands/index.pyÚadd_options   s   þzIndexCommand.add_optionsÚoptionsÚargsc              
   C   sœ   d| j i}t d¡ |r|d |vrt dd t|ƒ¡¡ tS |d }z|| ||dd … ƒ W t	S  tyM } zt |jd ¡ tW  Y d }~S d }~ww )NÚversionsztpip index is currently an experimental command. It may be removed/changed in a future release without prior warning.r   zNeed an action (%s) to perform.ú, é   )
Úget_available_package_versionsÚloggerÚwarningÚerrorÚjoinÚsortedr   r   r+   r   )r%   r*   r+   ÚhandlersÚactionÚer'   r'   r(   Úrun/   s(   ÿÿþü€þzIndexCommand.runÚsessionÚtarget_pythonr   c                 C   s6   t j||d�}td|j|d�}tj|||d|jv d�S )zK
        Create a package finder appropriate to the index command.
        )r*   F)Úallow_yankedÚallow_all_prereleasesr   Úhtml5lib)Úlink_collectorÚselection_prefsr:   Úuse_deprecated_html5lib)r   Úcreater   r   r   Údeprecated_features_enabled)r%   r*   r9   r:   r   r>   r?   r'   r'   r(   Ú_build_package_finderM   s   
ýüz"IndexCommand._build_package_finderc           
      C   sö   t |ƒdkr
tdƒ‚t |¡}|d }|  |¡�B}| j||||jd�}dd„ | |¡D ƒ}|js7dd„ |D ƒ}t	|ƒ}|sDt
d |¡ƒ‚d	d
„ t|dd�D ƒ}|d }	W d   ƒ n1 s]w   Y  td ||	¡ƒ td d |¡¡ƒ t||	ƒ d S )Nr.   z(You need to specify exactly one argumentr   )r*   r9   r:   r   c                 s   s   � | ]}|j V  qd S ©N)Úversion)Ú.0Ú	candidater'   r'   r(   Ú	<genexpr>v   s   € 
ÿz>IndexCommand.get_available_package_versions.<locals>.<genexpr>c                 s   s   � | ]}|j s|V  qd S rD   )Úis_prerelease)rF   rE   r'   r'   r(   rH   |   s   € ÿ
ÿz%No matching distribution found for {}c                 S   s   g | ]}t |ƒ‘qS r'   )Ústr)rF   Úverr'   r'   r(   Ú
<listcomp>†   s    z?IndexCommand.get_available_package_versions.<locals>.<listcomp>T)Úreversez{} ({})zAvailable versions: {}r-   )Úlenr   r
   Úmake_target_pythonÚ_build_sessionrC   r   Úfind_all_candidatesr   Úsetr   Úformatr4   r   r3   r   )
r%   r*   r+   r:   Úqueryr9   Úfinderr,   Úformatted_versionsÚlatestr'   r'   r(   r/   g   s:   
üÿÿÿ
çz+IndexCommand.get_available_package_versions)r   N)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager)   r   r   rJ   Úintr8   r   r   r   Úboolr   rC   r   r/   r'   r'   r'   r(   r      s&    
"ûþýüû
úr   ))ÚloggingÚoptparser   Útypingr   r   r   r   r   Úpip._vendor.packaging.versionr   r	   Úpip._internal.clir
   Úpip._internal.cli.req_commandr   Úpip._internal.cli.status_codesr   r   Úpip._internal.commands.searchr   Ú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   Ú	getLoggerrX   r0   r   r'   r'   r'   r(   Ú<module>   s"    
