a
    <Bìj¹4  ã                   @  sP  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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ƒZ.ddddœdd„Z/ddddœdd „Z0dS )!é    )ÚannotationsN)Ú	GeneratorÚ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/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pip/_internal/commands/list.pyr      s   
r   c                      sÎ   e Zd ZdZdZdZddœdd„Zddd	œ‡ fd
d„Zddddœdd„Zddddœdd„Z	ddddœdd„Z
ddddœdd„Zddddœdd„Zddddœdd „Zddddœd!d"„Zd#ddd$œd%d&„Z‡  ZS )'ÚListCommandzt
    List installed packages, including editables.

    Packages are listed in a case-insensitive sorted order.
    Tz
      %prog [options]ÚNone)Úreturnc                 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)r0   Ú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_pathZlist_excludeÚmake_option_groupÚindex_groupÚparserZpackage_selection_groupÚinsert_option_group)ÚselfÚ
index_optsZselection_optsr#   r#   r$   Úadd_options5   s�    ûûûú
ûùüüûþzListCommand.add_optionsr   )Úoptionsr'   c                   s   |j s|jrtƒ  |¡ d S ©N)ÚoutdatedÚuptodateÚsuperÚhandle_pip_version_check)r>   rA   ©Ú	__class__r#   r$   rF   Š   s    z$ListCommand.handle_pip_version_checkr   r   )rA   Úsessionr'   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   )rA   F)Úallow_yankedÚrelease_control)Úlink_collectorÚselection_prefs)Úpip._internal.index.collectorrJ   Ú"pip._internal.index.package_finderr   Úcreater   rL   )r>   rA   rI   rJ   r   rM   rN   r#   r#   r$   Ú_build_package_finderŽ   s    þþz!ListCommand._build_package_finderz	list[str]Úint)rA   Úargsr'   c                 C  sØ   t  |¡ |jr|jrtdƒ‚|jr6|jdkr6tdƒ‚t  |¡ ttƒ}|j	rd| 
dd„ |j	D ƒ¡ dd„ t|jƒj|j|j|j|j|d�D ƒ}|jr¢|  ||¡}|jr¶|  ||¡}n|jrÈ|  ||¡}|  ||¡ tS )	Nz5Options --outdated and --uptodate cannot be combined.r1   z?List format 'freeze' cannot be used with the --outdated option.c                 s  s   | ]}t |ƒV  qd S rB   r	   )Ú.0Únr#   r#   r$   Ú	<genexpr>´   ó    z"ListCommand.run.<locals>.<genexpr>c                 S  s   g | ]}t d |ƒ‘qS )r   )r   )rU   Údr#   r#   r$   Ú
<listcomp>¶   s   ÿz#ListCommand.run.<locals>.<listcomp>)Ú
local_onlyÚ	user_onlyÚeditables_onlyÚinclude_editablesÚskip)r   Zcheck_release_control_exclusiverC   rD   r   r/   Úcheck_list_path_optionÚsetr   ZexcludesÚupdater   ÚpathZiter_installed_distributionsÚlocalr,   Úeditabler6   r4   Úget_not_requiredÚget_outdatedÚget_uptodateÚoutput_package_listingr   )r>   rA   rT   r_   Úpackagesr#   r#   r$   Úrun¥   s8    
ÿ

ûþzListCommand.runÚ_ProcessedDists©rj   rA   r'   c                 C  s   dd„ |   ||¡D ƒS )Nc                 S  s   g | ]}|j |jkr|‘qS r#   ©r   Úversion©rU   Údistr#   r#   r$   rZ   Ó   s   þz,ListCommand.get_outdated.<locals>.<listcomp>©Úiter_packages_latest_infos©r>   rj   rA   r#   r#   r$   rg   Ð   s    
þzListCommand.get_outdatedc                 C  s   dd„ |   ||¡D ƒS )Nc                 S  s   g | ]}|j |jkr|‘qS r#   rn   rp   r#   r#   r$   rZ   Ü   s   þz,ListCommand.get_uptodate.<locals>.<listcomp>rr   rt   r#   r#   r$   rh   Ù   s    
þ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#   )Ziter_dependenciesr
   Úname)rU   rq   Údepr#   r#   r$   Ú	<setcomp>å   s   þz/ListCommand.get_not_required.<locals>.<setcomp>c                   s   h | ]}|j ˆ vr|’qS r#   ©Úcanonical_name)rU   Úpkg©Zdep_keysr#   r$   rw   î   rX   )Úlistrt   r#   r{   r$   rf   â   s    þ	zListCommand.get_not_requiredz*Generator[_DistWithLatestInfo, None, None]c                 #  sp   ˆ  ˆ¡�R}ˆ ˆ|¡‰ dddœ‡ ‡‡fdd„}t||ƒD ]}|d ur:|V  q:W d   ƒ n1 sb0    Y  d S )Nr   z_DistWithLatestInfo | None©rq   r'   c                   st   ˆ   | j¡}ˆ ˆ| j¡r(dd„ |D ƒ}ˆ j| jd�}| |¡}|d u rLd S |j}|jjr`d}nd}|| _|| _	| S )Nc                 S  s   g | ]}|j js|‘qS r#   )ro   Úis_prerelease)rU   Ú	candidater#   r#   r$   rZ   û   s   þzOListCommand.iter_packages_latest_infos.<locals>.latest_info.<locals>.<listcomp>)Úproject_nameÚwheelÚsdist)
Úfind_all_candidatesry   Zshould_exclude_prereleaseÚmake_candidate_evaluatorÚsort_best_candidatero   ÚlinkÚis_wheelr   r   )rq   Zall_candidatesZ	evaluatorÚbest_candidateÚremote_versionÚtyp©ÚfinderrA   r>   r#   r$   Úlatest_infoö   s$    þÿ
z;ListCommand.iter_packages_latest_infos.<locals>.latest_info)Ú_build_sessionrR   Úmap)r>   rj   rA   rI   r�   rq   r#   r‹   r$   rs   ð   s    z&ListCommand.iter_packages_latest_infosc              	   C  sÊ   t |dd„ d�}|jdkr:|r:t||ƒ\}}|  ||¡ nŒ|jdkr®|D ]b}z|j› d|j› �}W n$ ty†   |j› d|j› �}Y n0 |jdkr¢t	d	||j
ƒ qHt	|ƒ qHn|jd
krÆt	t||ƒƒ d S )Nc                 S  s   | j S rB   rx   )rq   r#   r#   r$   Ú<lambda>  rX   z4ListCommand.output_package_listing.<locals>.<lambda>)Úkeyr0   r1   z==z===é   z%s (%s)r2   )Úsortedr/   Úformat_for_columnsÚoutput_package_listing_columnsÚraw_namero   r   Úraw_versionÚverboser   ÚlocationÚformat_for_json)r>   rj   rA   ÚdataÚheaderrq   Ú
req_stringr#   r#   r$   ri     s$    þ


z"ListCommand.output_package_listingzlist[list[str]])r›   rœ   r'   c                 C  sb   t |ƒdkr| d|¡ t|ƒ\}}t |ƒdkrL| dd dd„ |D ƒ¡¡ |D ]}t|ƒ qPd S )Nr   r’   ú c                 s  s   | ]}d | V  qdS )ú-Nr#   ©rU   Úxr#   r#   r$   rW   7  rX   z=ListCommand.output_package_listing_columns.<locals>.<genexpr>)ÚlenÚinsertr   Újoinr   )r>   r›   rœ   Zpkg_stringsÚsizesÚvalr#   r#   r$   r•   ,  s    z*ListCommand.output_package_listing_columns)r   r   r    r!   Úignore_require_venvÚusager@   rF   rR   rk   rg   rh   rf   rs   ri   r•   Ú__classcell__r#   r#   rG   r$   r%   *   s   U+		%r%   rl   r   z!tuple[list[list[str]], list[str]])ÚpkgsrA   r'   c                   sX  ddg}|j }|r | ddg¡ dddœdd	„‰ ‡ fd
d„| D ƒ}t|ƒ}|rX| d¡ tdd„ | D ƒƒ}|rx| d¡ |jdkrŒ| d¡ |jdkr | d¡ g }t| ƒD ]¢\}}	|	j|	jg}
|rà|
 t|	j	ƒ¡ |
 |	j
¡ |rö|
 || pòd¡ |�r|
 |	j�p
d¡ |jdk�r,|
 |	j�p(d¡ |jdk�rD|
 |	j¡ | |
¡ q¬||fS )z_
    Convert the package data into something usable
    by output_package_listing_columns.
    ÚPackager   ZLatestÚTyper   z
str | Noner}   c                 S  s6   z|   d¡}W n ty"   Y d S 0 tƒ  |¡ d¡S )NZWHEELÚBuild)Ú	read_textÚFileNotFoundErrorr   ÚparsestrÚget)rq   Ú
wheel_filer#   r#   r$   Úwheel_build_tagJ  s
    z+format_for_columns.<locals>.wheel_build_tagc                   s   g | ]}ˆ |ƒ‘qS r#   r#   )rU   Úp©r³   r#   r$   rZ   Q  rX   z&format_for_columns.<locals>.<listcomp>r­   c                 s  s   | ]}|j V  qd S rB   )re   r    r#   r#   r$   rW   V  rX   z%format_for_columns.<locals>.<genexpr>zEditable project locationr’   ZLocationZ	InstallerÚ )rC   ÚextendÚanyÚappendr˜   Ú	enumerater–   r—   r   r   r   Úeditable_project_locationr™   Ú	installer)rª   rA   rœ   Zrunning_outdatedZ
build_tagsZhas_build_tagsZhas_editablesr›   ÚiZprojÚrowr#   rµ   r$   r”   =  s@    





r”   r   rm   c              	   C  s¨   g }| D ]”}zt |jƒ}W n ty2   |j}Y n0 |j|dœ}|jdkrb|jpRd|d< |j|d< |jr€t |j	ƒ|d< |j
|d< |j}|r’||d< | |¡ qt |¡S )	N)ru   ro   r’   r¶   r™   r¼   r   r   r»   )r   ro   r   r—   r–   r˜   r™   r¼   rC   r   r   r»   r¹   r2   Údumps)rj   rA   r›   rq   ro   Úinfor»   r#   r#   r$   rš   y  s(    þ


rš   )1Ú
__future__r   r2   ÚloggingÚcollections.abcr   r   Úemail.parserr   Úoptparser   Útypingr   r   Zpip._vendor.packaging.utilsr
   Úpip._vendor.packaging.versionr   r   Zpip._internal.clir   Zpip._internal.cli.index_commandr   Úpip._internal.cli.status_codesr   Úpip._internal.exceptionsr   Zpip._internal.metadatar   r   Ú$pip._internal.models.selection_prefsr   Úpip._internal.utils.compatr   Úpip._internal.utils.miscr   r   rP   r   Úpip._internal.network.sessionr   r   rl   Ú	getLoggerr   Úloggerr%   r”   rš   r#   r#   r#   r$   Ú<module>   s6   

  <