o
    6‘ðiF5  ã                   @  sJ  d dl mZ d dlZd dlZd dl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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 d dlmZmZ d dl m!Z! d dl"m#Z# d dl$m%Z%m&Z& erŒd dl'm(Z( d dl)m*Z* G dd„ deƒZ+ee+ Z,e -e.¡Z/G dd„ deƒZ0d#dd„Z1d$d!d"„Z2dS )%é    )ÚannotationsN)Ú	GeneratorÚIteratorÚSequence)ÚParser)ÚValues)ÚTYPE_CHECKINGÚcast©Úcanonicalize_name)ÚInvalidVersionÚVersion)Ú
cmdoptions)ÚIndexGroupCommand)ÚSUCCESS)ÚCommandError)ÚBaseDistributionÚget_environment)ÚSelectionPreferences)Ústdlib_pkgs)ÚtabulateÚwrite_output©ÚPackageFinder)Ú
PipSessionc                   @  s"   e Zd ZU dZded< ded< dS )Ú_DistWithLatestInfoz¾Give the distribution object a couple of extra fields.

        These will be populated during ``get_outdated()``. This is dirty but
        makes the rest of the code much cleaner.
        r   Úlatest_versionÚstrÚlatest_filetypeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© r$   r$   úZ/root/parts/websockify/install/lib/python3.10/site-packages/pip/_internal/commands/list.pyr      s   
 r   c                      sŠ   e Zd ZdZdZdZd)dd„Zejd*‡ fdd„ƒZ	d+dd„Z
d,dd„Zd-dd„Zd-dd„Zd-dd„Zd.d d!„Zd/d"d#„Zd0d'd(„Z‡  ZS )1ÚListCommandzt
    List installed packages, including editables.

    Packages are listed in a case-insensitive sorted order.
    Tz
      %prog [options]ÚreturnÚNonec                 C  s4  | j jdddddd� | j jddddd	d� | j jd
ddddd� | j jdddddd� | j jdddddd� | j  t ¡ ¡ | j jddddddd� | j jddddd� | j jdd d!d"d� | j jd#dd!d$d%d&� | j  t ¡ ¡ t tj| j¡}t tj| j¡}| j 	d'|¡ | j 	d'|¡ | j 	d'| j ¡ d S )(Nz-oz
--outdatedÚ
store_trueFzList outdated packages)ÚactionÚdefaultÚhelpz-uz
--uptodatezList uptodate packagesz-ez
--editablezList editable projects.z-lz--localzSIf in a virtualenv that has global access, do not list globally-installed packages.z--userÚuserz,Only output packages installed in user-site.)Údestr*   r+   r,   z--formatÚstoreÚlist_formatÚcolumns)r1   ÚfreezeÚjsonz‚Select the output format among: columns (default), freeze, or json. The 'freeze' format cannot be used with the --outdated option.)r*   r.   r+   Úchoicesr,   z--not-requiredÚnot_requiredz>List packages that are not dependencies of installed packages.)r*   r.   r,   z--exclude-editableÚstore_falseÚinclude_editablez%Exclude editable package from output.z--include-editablez#Include editable package in output.T)r*   r.   r,   r+   r   )
Úcmd_optsÚ
add_optionr   Ú	list_pathÚlist_excludeÚmake_option_groupÚindex_groupÚparserÚpackage_selection_groupÚinsert_option_group)ÚselfÚ
index_optsÚselection_optsr$   r$   r%   Úadd_options6   s�   ûûûú
ûùüüûþzListCommand.add_optionsÚoptionsr   Úargsú	list[str]úIterator[None]c                 #  sR   � |j s|jsd V  d S tƒ  ||¡� d V  W d   ƒ d S 1 s"w   Y  d S ©N)ÚoutdatedÚuptodateÚsuperÚpip_version_check)rA   rE   rF   ©Ú	__class__r$   r%   rM   ‹   s   €"ÿzListCommand.pip_version_checkÚsessionr   r   c                 C  sB   ddl m} ddlm} |j||d�}td|jd�}|j||d�S )zK
        Create a package finder appropriate to this list command.
        r   )ÚLinkCollectorr   )rE   F)Úallow_yankedÚrelease_control)Úlink_collectorÚselection_prefs)Úpip._internal.index.collectorrQ   Ú"pip._internal.index.package_finderr   Úcreater   rS   )rA   rE   rP   rQ   r   rT   rU   r$   r$   r%   Ú_build_package_finder“   s   þþz!ListCommand._build_package_finderÚintc                 C  sØ   t  |¡ |jr|jrtdƒ‚|jr|jdkrtdƒ‚t  |¡ ttƒ}|j	r2| 
dd„ |j	D ƒ¡ dd„ t|jƒj|j|j|j|j|d�D ƒ}|jrQ|  ||¡}|jr[|  ||¡}n	|jrd|  ||¡}|  ||¡ tS )	Nz5Options --outdated and --uptodate cannot be combined.r2   z?List format 'freeze' cannot be used with the --outdated option.c                 s  s   � | ]}t |ƒV  qd S rI   r
   )Ú.0Únr$   r$   r%   Ú	<genexpr>¹   ó   € z"ListCommand.run.<locals>.<genexpr>c                 S  s   g | ]}t d |ƒ‘qS )r   )r	   )r[   Údr$   r$   r%   Ú
<listcomp>»   s    ÿÿz#ListCommand.run.<locals>.<listcomp>)Ú
local_onlyÚ	user_onlyÚeditables_onlyÚinclude_editablesÚskip)r   Úcheck_release_control_exclusiverJ   rK   r   r0   Úcheck_list_path_optionÚsetr   ÚexcludesÚupdater   ÚpathÚiter_installed_distributionsÚlocalr-   Úeditabler7   r5   Úget_not_requiredÚget_outdatedÚget_uptodateÚoutput_package_listingr   )rA   rE   rF   re   Úpackagesr$   r$   r%   Úrunª   s8   
ÿ

ûþzListCommand.runrs   Ú_ProcessedDistsc                 C  ó   dd„ |   ||¡D ƒS )Nc                 S  s   g | ]
}|j |jkr|‘qS r$   ©r   Úversion©r[   Údistr$   r$   r%   r`   Ø   ó
    þz,ListCommand.get_outdated.<locals>.<listcomp>©Úiter_packages_latest_infos©rA   rs   rE   r$   r$   r%   rp   Õ   ó   
þzListCommand.get_outdatedc                 C  rv   )Nc                 S  s   g | ]
}|j |jkr|‘qS r$   rw   ry   r$   r$   r%   r`   á   r{   z,ListCommand.get_uptodate.<locals>.<listcomp>r|   r~   r$   r$   r%   rq   Þ   r   zListCommand.get_uptodatec                   s$   dd„ |D ƒ‰ t ‡ fdd„|D ƒƒS )Nc                 S  s(   h | ]}|  ¡ p	d D ]}t|jƒ’q
qS )r$   )Úiter_dependenciesr   Úname)r[   rz   Údepr$   r$   r%   Ú	<setcomp>ê   s    
ýþÿz/ListCommand.get_not_required.<locals>.<setcomp>c                   s   h | ]	}|j ˆ vr|’qS r$   ©Úcanonical_name)r[   Úpkg©Údep_keysr$   r%   rƒ   ó   s    )Úlistr~   r$   r‡   r%   ro   ç   s   þ	zListCommand.get_not_requiredú*Generator[_DistWithLatestInfo, None, None]c                 #  sn   � ˆ  ˆ¡�'}ˆ ˆ|¡‰ d‡ ‡‡fdd„}t||ƒD ]	}|d ur$|V  qW d   ƒ d S 1 s0w   Y  d S )Nrz   r   r'   ú_DistWithLatestInfo | Nonec                   st   ˆ   | j¡}ˆ ˆ| j¡rdd„ |D ƒ}ˆ j| jd�}| |¡}|d u r&d S |j}|jjr0d}nd}|| _|| _	| S )Nc                 S  s   g | ]}|j js|‘qS r$   )rx   Úis_prerelease)r[   Ú	candidater$   r$   r%   r`      s    ýÿzOListCommand.iter_packages_latest_infos.<locals>.latest_info.<locals>.<listcomp>)Úproject_nameÚwheelÚsdist)
Úfind_all_candidatesr…   Úshould_exclude_prereleaseÚmake_candidate_evaluatorÚsort_best_candidaterx   ÚlinkÚis_wheelr   r   )rz   Úall_candidatesÚ	evaluatorÚbest_candidateÚremote_versionÚtyp©ÚfinderrE   rA   r$   r%   Úlatest_infoû   s$   þÿ
z;ListCommand.iter_packages_latest_infos.<locals>.latest_info)rz   r   r'   r‹   )Ú_build_sessionrY   Úmap)rA   rs   rE   rP   rž   rz   r$   rœ   r%   r}   õ   s   €€þ"âz&ListCommand.iter_packages_latest_infosc              	   C  sÒ   t |dd„ d�}|jdkr|rt||ƒ\}}|  ||¡ d S |jdkrY|D ]1}z|j› d|j› �}W n tyD   |j› d|j› �}Y nw |jdkrRt	d	||j
ƒ q%t	|ƒ q%d S |jd
krgt	t||ƒƒ d S d S )Nc                 S  s   | j S rI   r„   )rz   r$   r$   r%   Ú<lambda>  s    z4ListCommand.output_package_listing.<locals>.<lambda>)Úkeyr1   r2   z==z===é   z%s (%s)r3   )Úsortedr0   Úformat_for_columnsÚoutput_package_listing_columnsÚraw_namerx   r   Úraw_versionÚverboser   ÚlocationÚformat_for_json)rA   rs   rE   ÚdataÚheaderrz   Ú
req_stringr$   r$   r%   rr     s*   þ
ÿ

ø
	ÿz"ListCommand.output_package_listingr¬   úlist[list[str]]r­   c                 C  sb   t |ƒdkr| d|¡ t|ƒ\}}t |ƒdkr&| dd dd„ |D ƒ¡¡ |D ]}t|ƒ q(d S )Nr   r£   ú c                 s  s   � | ]}d | V  qdS )ú-Nr$   ©r[   Úxr$   r$   r%   r]   <  r^   z=ListCommand.output_package_listing_columns.<locals>.<genexpr>)ÚlenÚinsertr   Újoinr   )rA   r¬   r­   Úpkg_stringsÚsizesÚvalr$   r$   r%   r¦   1  s   
ÿz*ListCommand.output_package_listing_columns)r'   r(   )rE   r   rF   rG   r'   rH   )rE   r   rP   r   r'   r   )rE   r   rF   rG   r'   rZ   )rs   ru   rE   r   r'   ru   )rs   ru   rE   r   r'   rŠ   )rs   ru   rE   r   r'   r(   )r¬   r¯   r­   rG   r'   r(   )r   r    r!   r"   Úignore_require_venvÚusagerD   Ú
contextlibÚcontextmanagerrM   rY   rt   rp   rq   ro   r}   rr   r¦   Ú__classcell__r$   r$   rN   r%   r&   +   s    
U


+
	
	

%r&   Úpkgsru   rE   r   r'   ú!tuple[list[list[str]], list[str]]c                   sH  ddg}|j }|r| ddg¡ dd	d
„‰ ‡ fdd„| D ƒ}t|ƒ}|r)| d¡ tdd„ | D ƒƒ}|r9| d¡ |jdkrC| d¡ |jdkrM| d¡ g }t| ƒD ]L\}}	|	j|	jg}
|rm|
 t|	j	ƒ¡ |
 |	j
¡ |rx|
 || pvd¡ |r‚|
 |	jp€d¡ |jdkr�|
 |	jp�d¡ |jdkrš|
 |	j¡ | |
¡ qS||fS )z_
    Convert the package data into something usable
    by output_package_listing_columns.
    ÚPackager   ÚLatestÚTyperz   r   r'   ú
str | Nonec                 S  s6   z|   d¡}W n
 ty   Y d S w tƒ  |¡ d¡S )NÚWHEELÚBuild)Ú	read_textÚFileNotFoundErrorr   ÚparsestrÚget)rz   Ú
wheel_filer$   r$   r%   Úwheel_build_tagO  s   ÿz+format_for_columns.<locals>.wheel_build_tagc                   s   g | ]}ˆ |ƒ‘qS r$   r$   )r[   Úp©rÌ   r$   r%   r`   V  s    z&format_for_columns.<locals>.<listcomp>rÆ   c                 s  s   � | ]}|j V  qd S rI   )rn   r²   r$   r$   r%   r]   [  s   € z%format_for_columns.<locals>.<genexpr>zEditable project locationr£   ÚLocationÚ	InstallerÚ N)rz   r   r'   rÄ   )rJ   ÚextendÚanyÚappendr©   Ú	enumerater§   r¨   r   r   r   Úeditable_project_locationrª   Ú	installer)r¿   rE   r­   Úrunning_outdatedÚ
build_tagsÚhas_build_tagsÚhas_editablesr¬   ÚiÚprojÚrowr$   rÎ   r%   r¥   B  s@   








r¥   rs   r   c              	   C  s¨   g }| D ]J}zt |jƒ}W n ty   |j}Y nw |j|dœ}|jdkr1|jp)d|d< |j|d< |jr@t |j	ƒ|d< |j
|d< |j}|rI||d< | |¡ qt |¡S )	N)r�   rx   r£   rÑ   rª   r×   r   r   rÖ   )r   rx   r   r¨   r§   r©   rª   r×   rJ   r   r   rÖ   rÔ   r3   Údumps)rs   rE   r¬   rz   rx   ÚinforÖ   r$   r$   r%   r«   ~  s*   
ÿþ



r«   )r¿   ru   rE   r   r'   rÀ   )rs   ru   rE   r   r'   r   )3Ú
__future__r   r¼   r3   ÚloggingÚcollections.abcr   r   r   Úemail.parserr   Úoptparser   Útypingr   r	   Úpip._vendor.packaging.utilsr   Úpip._vendor.packaging.versionr   r   Úpip._internal.clir   Úpip._internal.cli.index_commandr   Úpip._internal.cli.status_codesr   Úpip._internal.exceptionsr   Úpip._internal.metadatar   r   Ú$pip._internal.models.selection_prefsr   Úpip._internal.utils.compatr   Úpip._internal.utils.miscr   r   rW   r   Úpip._internal.network.sessionr   r   ru   Ú	getLoggerr   Úloggerr&   r¥   r«   r$   r$   r$   r%   Ú<module>   s:    

  
<