o
    ©„jè  ã                   @  s  d dl mZ d dlZd dl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 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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)ÚCallableÚIterable)ÚValues)ÚAny)Úcanonicalize_name)ÚVersion)Ú
cmdoptions)ÚIndexGroupCommand)ÚERRORÚSUCCESS)Úget_installed_distributionÚprint_dist_installation_info)ÚCommandErrorÚDiagnosticPipErrorÚDistributionNotFoundÚPipError)ÚLinkCollector)ÚPackageFinder)ÚSelectionPreferences)ÚTargetPython)Ú
PipSession)Úwrite_outputc                   @  sP   e Zd ZdZdZdZd dd„Zd!d	d
„Zd"dd„Z		d#d$dd„Z	d%dd„Z
dS )&ÚIndexCommandz=
    Inspect information available from package indexes.
    Tz&
        %prog versions <package>
    ÚreturnÚNonec                 C  s|   t  | j¡ | j t  ¡ ¡ | j t  ¡ ¡ t  t j| j¡}t  t j	| j¡}| j 
d|¡ | j 
d|¡ | j 
d| j¡ d S )Nr   )r	   Úadd_target_python_optionsÚcmd_optsÚ
add_optionÚignore_requires_pythonÚjsonÚmake_option_groupÚindex_groupÚparserÚpackage_selection_groupÚinsert_option_group)ÚselfÚ
index_optsÚselection_opts© r)   úZ/var/www/html/django_cbt/venv/lib/python3.10/site-packages/pip/_internal/commands/index.pyÚadd_options-   s   þþzIndexCommand.add_optionsú.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_mapA   s   ÿzIndexCommand.handler_mapÚoptionsr   Úargsú	list[str]Úintc              
   C  s¨   t  |¡ |  ¡ }|r|d |vrt dd t|ƒ¡¡ tS |d }z|| ||dd … ƒ W tS  ty8   ‚  t	yS } zt |j
d ¡ tW  Y d }~S d }~ww )Nr   zNeed an action (%s) to perform.ú, é   )r	   Úcheck_release_control_exclusiver/   ÚloggerÚerrorÚjoinÚsortedr   r   r   r1   r   )r&   r0   r1   r/   ÚactionÚer)   r)   r*   ÚrunF   s&   
þú€þzIndexCommand.runNFÚsessionr   Útarget_pythonúTargetPython | Noner   Úboolr   c                 C  s6   t j||d�}td|j|j|d�}tj||||jd�S )zK
        Create a package finder appropriate to the index command.
        )r0   F)Úallow_yankedÚrelease_controlÚformat_controlr   )Úlink_collectorÚselection_prefsr?   Úuploaded_prior_to)r   Úcreater   rC   rD   r   rG   )r&   r0   r>   r?   r   rE   rF   r)   r)   r*   Ú_build_package_finder`   s   
üüz"IndexCommand._build_package_finderú	list[Any]c                 C  sF  t |ƒdkr
tdƒ‚t |¡}|d }|  |¡�G}| j||||jd�}dd„ | |¡D ƒ}|  |t	|ƒ¡r<dd„ |D ƒ}t
|ƒ}|sItd|› �ƒ‚d	d
„ t|dd�D ƒ}|d }	W d   ƒ n1 sbw   Y  t|ƒ}
|jrˆ|||	dœ}|
d urt|
jƒ|d< tt |¡ƒ d S t|› d|	› d�ƒ td d |¡¡ƒ t|	|
ƒ d S )Nr5   z(You need to specify exactly one argumentr   )r0   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 rK   )Úis_prerelease)rM   rL   r)   r)   r*   rO   �   s   € ÿ
ÿz#No matching distribution found for c                 S  s   g | ]}t |ƒ‘qS r)   )Ústr)rM   Úverr)   r)   r*   Ú
<listcomp>™   s    z?IndexCommand.get_available_package_versions.<locals>.<listcomp>T)Úreverse)Únamer-   ÚlatestÚinstalled_versionz (ú)zAvailable versions: {}r4   )Úlenr   r	   Úmake_target_pythonÚ_build_sessionrI   r   Úfind_all_candidatesÚshould_exclude_prereleaser   Úsetr   r:   r   r    rQ   rL   r   ÚdumpsÚformatr9   r   )r&   r0   r1   r?   Úqueryr>   Úfinderr-   Úformatted_versionsrV   ÚdistÚstructured_outputr)   r)   r*   r.   {   sL   
üÿÿÿ
èýz+IndexCommand.get_available_package_versions)r   r   )r   r,   )r0   r   r1   r2   r   r3   )NF)
r0   r   r>   r   r?   r@   r   rA   r   r   )r0   r   r1   rJ   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úignore_require_venvÚusager+   r/   r=   rI   r.   r)   r)   r)   r*   r   #   s    


ûr   ).Ú
__future__r   r    ÚloggingÚcollections.abcr   r   Úoptparser   Útypingr   Úpip._vendor.packaging.utilsr   Úpip._vendor.packaging.versionr   Úpip._internal.clir	   Úpip._internal.cli.req_commandr
   Úpip._internal.cli.status_codesr   r   Úpip._internal.commands.searchr   r   Úpip._internal.exceptionsr   r   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   Ú	getLoggerrf   r7   r   r)   r)   r)   r*   Ú<module>   s*    
