U ��.e4)�@s�ddlmZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZmZmZdd lmZe�e�ZGd d�de �Zdd�Zdd�Zdd�Z dS)�)�absolute_importN)�six)� zip_longest)� cmdoptions)�IndexGroupCommand)� CommandError)� PackageFinder)�SelectionPreferences)�make_link_collector)�dist_is_editable�get_installed_distributions� write_output)� get_installercsdeZdZdZdZ�fdd�Zdd�Zdd�Zd d �Zd d �Z d d�Z dd�Z dd�Z dd�Z �ZS)� ListCommandzt List installed packages, including editables. Packages are listed in a case-insensitive sorted order. z %prog [options]cstt|�j||�|j}|jdddddd�|jddddd d�|jd d ddd d�|jd ddddd�|jjdddddd�|�t���|jddddd�|jddddddd�|jddddd �|jd!d"d#d$d �|jd%dd#d&d'd(�t�tj|j �}|j � d)|�|j � d)|�dS)*Nz-oz --outdated� store_trueFzList outdated packages)�action�default�helpz-uz --uptodatezList uptodate packagesz-ez --editablezList 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.)�destrrrz--prezYInclude pre-release and development versions. By default, pip only finds stable versions.z--formatZstore� list_format�columns)r�freeze�jsonzBSelect the output format among: columns (default), freeze, or json)rrr�choicesrz--not-required� not_requiredz>List packages that are not dependencies of installed packages.)rrrz--exclude-editableZ store_false�include_editablez%Exclude editable package from output.z--include-editablez%Include editable package from output.T)rrrrr) �superr�__init__�cmd_optsZ add_optionrZ list_pathZmake_option_groupZ index_group�parserZinsert_option_group)�self�args�kwrZ index_opts�� __class__��?/usr/lib/python3.8/site-packages/pip/_internal/commands/list.pyr&s�������� ����zListCommand.__init__cCs(t||d�}td|jd�}tj||d�S)zK Create a package finder appropriate to this list command. )�optionsF)Z allow_yankedZallow_all_prereleases)�link_collector�selection_prefs)r r �prerZcreate)r!r(�sessionr)r*r&r&r'�_build_package_findervs ��z!ListCommand._build_package_findercCs�|jr|jrtd��t�|�t|j|j|j|j |j d�}|j rL|� ||�}|jr`|� ||�}n|jrr|�||�}|�||�dS)Nz5Options --outdated and --uptodate cannot be combined.)Z local_onlyZ user_onlyZeditables_onlyZinclude_editables�paths)�outdatedZuptodaterrZcheck_list_path_optionr ZlocalrZeditabler�pathr�get_not_required� get_outdated� get_uptodate�output_package_listing)r!r(r"�packagesr&r&r'�run�s& � �   zListCommand.runcCsdd�|�||�D�S)NcSsg|]}|j|jkr|�qSr&��latest_versionZparsed_version��.0�distr&r&r'� �s �z,ListCommand.get_outdated..��iter_packages_latest_infos�r!r5r(r&r&r'r2�s �zListCommand.get_outdatedcCsdd�|�||�D�S)NcSsg|]}|j|jkr|�qSr&r7r9r&r&r'r<�s �z,ListCommand.get_uptodate..r=r?r&r&r'r3�s �zListCommand.get_uptodatecs:t��|D]}��dd�|��D��q �fdd�|D�S)Ncss|] }|jVqdS�N��key)r:Z requirementr&r&r'� �sz/ListCommand.get_not_required..csh|]}|j�kr|�qSr&rA)r:Zpkg�Zdep_keysr&r'� �s z/ListCommand.get_not_required..)�set�updateZrequires)r!r5r(r;r&rDr'r1�szListCommand.get_not_requiredc cs�|�|���}|�||�}|D]t}d}|�|j�}|jsDdd�|D�}|j|jd�}|�|�} | dkrfq| j} | j j rzd}nd}| |_ ||_ |VqW5QRXdS)N�unknowncSsg|]}|jjs|�qSr&)�versionZ is_prerelease)r:� candidater&r&r'r<�s�z:ListCommand.iter_packages_latest_infos..)� project_nameZwheelZsdist) Z_build_sessionr-Zfind_all_candidatesrBr+Zmake_candidate_evaluatorrKZsort_best_candidaterI�linkZis_wheelr8�latest_filetype) r!r5r(r,�finderr;�typZall_candidatesZ evaluatorZbest_candidateZremote_versionr&r&r'r>�s(   � z&ListCommand.iter_packages_latest_infoscCs�t|dd�d�}|jdkr:|r:t||�\}}|�||�n^|jdkr�|D]4}|jdkrltd|j|j|j�qHtd|j|j�qHn|jd kr�tt ||��dS) NcSs |j��Sr@)rK�lower)r;r&r&r'���z4ListCommand.output_package_listing..rArr�z %s==%s (%s)z%s==%sr) �sortedr�format_for_columns�output_package_listing_columns�verboser rKrI�location�format_for_json)r!r5r(�data�headerr;r&r&r'r4�s"�  � z"ListCommand.output_package_listingcCsbt|�dkr|�d|�t|�\}}t|�dkrL|�dd�tdd�|���|D] }t|�qPdS)NrrS� cSsd|S)N�-r&)�xr&r&r'rQ�rRz.)�len�insert�tabulate�join�mapr )r!rZr[Z pkg_strings�sizes�valr&r&r'rV�s    z*ListCommand.output_package_listing_columns)�__name__� __module__� __qualname__�__doc__Zusagerr-r6r2r3r1r>r4rV� __classcell__r&r&r$r'rs PrcCspdgtdd�|D��}|D]}dd�t||�D�}qg}|D](}d�dd�t||�D��}|�|�q>||fS)Nrcss|]}t|�VqdSr@)r_�r:r^r&r&r'rC�sztabulate..cSs"g|]\}}t|tt|����qSr&)�maxr_�str�r:�s�cr&r&r'r<�sztabulate..r\cSs*g|]"\}}|dk r"t|��|�nd�qS)N�)rm�ljustrnr&r&r'r<�s�)rlrrb�append)Zvalsrd�row�resultZdisplayr&r&r'ra�s � racCs�|j}|rddddg}nddg}g}|jdks@tdd�|D��rJ|�d�|jdkr^|�d �|D]l}|j|jg}|r�|�|j�|�|j�|jdks�t|�r�|�|j �|jdkr�|�t |��|�|�qb||fS) z_ Convert the package data into something usable by output_package_listing_columns. ZPackageZVersionZLatestZTyperScss|]}t|�VqdSr@)r rkr&r&r'rCsz%format_for_columns..ZLocationZ Installer) r/rW�anyrsrKrIr8rMr rXr)Zpkgsr(Zrunning_outdatedr[rZZprojrtr&r&r'rUs(         rUcCsvg}|D]b}|jt�|j�d�}|jdkr@|j|d<t|�|d<|jr`t�|j�|d<|j |d<|� |�qt � |�S)N)�namerIrSrXZ installerr8rM) rKrZ text_typerIrWrXrr/r8rMrsr�dumps)r5r(rZr;�infor&r&r'rY+s �     rY)!Z __future__rrZloggingZ pip._vendorrZpip._vendor.six.movesrZpip._internal.clirZpip._internal.cli.req_commandrZpip._internal.exceptionsrZpip._internal.indexrZ$pip._internal.models.selection_prefsr Z!pip._internal.self_outdated_checkr Zpip._internal.utils.miscr r r Zpip._internal.utils.packagingrZ getLoggerrfZloggerrrarUrYr&r&r&r'�s$           Y%