U .e4)@sddlmZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZmZmZdd lmZeeZGd dde ZddZddZddZ dS))absolute_importN)six) zip_longest) cmdoptions)IndexGroupCommand) CommandError) PackageFinder)SelectionPreferences)make_link_collector)dist_is_editableget_installed_distributions write_output) get_installercsdeZdZdZdZfddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ 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(ttj|j }|j d)||j d)|dS)*Nz-oz --outdated store_trueFzList outdated packages)actiondefaulthelpz-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--useruserz,Only output packages installed in user-site.)destrrrz--prezYInclude pre-release and development versions. By default, pip only finds stable versions.z--formatZstore list_formatcolumns)rfreezejsonzBSelect the output format among: columns (default), freeze, or json)rrrchoicesrz--not-required not_requiredz>List packages that are not dependencies of installed packages.)rrrz--exclude-editableZ store_falseinclude_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_groupparserZinsert_option_group)selfargskwrZ index_opts __class__?/usr/lib/python3.8/site-packages/pip/_internal/commands/list.pyr&s zListCommand.__init__cCs(t||d}td|jd}tj||dS)zK Create a package finder appropriate to this list command. )optionsF)Z allow_yankedZallow_all_prereleases)link_collectorselection_prefs)r r prerZcreate)r!r(sessionr)r*r&r&r'_build_package_findervs z!ListCommand._build_package_findercCs|jr|jrtdt|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_editablespaths)outdatedZuptodaterrZcheck_list_path_optionr ZlocalrZeditablerpathrget_not_required get_outdated get_uptodateoutput_package_listing)r!r(r"packagesr&r&r'runs&     zListCommand.runcCsdd|||DS)NcSsg|]}|j|jkr|qSr&latest_versionZparsed_version.0distr&r&r' s z,ListCommand.get_outdated..iter_packages_latest_infosr!r5r(r&r&r'r2s zListCommand.get_outdatedcCsdd|||DS)NcSsg|]}|j|jkr|qSr&r7r9r&r&r'r<s z,ListCommand.get_uptodate..r=r?r&r&r'r3s zListCommand.get_uptodatecs:t|D]}dd|Dq fdd|DS)Ncss|] }|jVqdSNkey)r:Z requirementr&r&r' sz/ListCommand.get_not_required..csh|]}|jkr|qSr&rA)r:ZpkgZdep_keysr&r' s z/ListCommand.get_not_required..)setupdateZrequires)r!r5r(r;r&rDr'r1szListCommand.get_not_requiredc cs||}|||}|D]t}d}||j}|jsDdd|D}|j|jd}||} | dkrfq| j} | j j rzd}nd}| |_ ||_ |VqW5QRXdS)NunknowncSsg|]}|jjs|qSr&)versionZ is_prerelease)r: candidater&r&r'r<sz:ListCommand.iter_packages_latest_infos..) project_nameZwheelZsdist) Z_build_sessionr-Zfind_all_candidatesrBr+Zmake_candidate_evaluatorrKZsort_best_candidaterIlinkZis_wheelr8latest_filetype) r!r5r(r,finderr;typZall_candidatesZ evaluatorZbest_candidateZremote_versionr&r&r'r>s(    z&ListCommand.iter_packages_latest_infoscCst|ddd}|jdkr:|r:t||\}}|||n^|jdkr|D]4}|jdkrltd|j|j|jqHtd|j|jqHn|jd krtt ||dS) NcSs |jSr@)rKlower)r;r&r&r'z4ListCommand.output_package_listing..rArrz %s==%s (%s)z%s==%sr) sortedrformat_for_columnsoutput_package_listing_columnsverboser rKrIlocationformat_for_json)r!r5r(dataheaderr;r&r&r'r4s"   z"ListCommand.output_package_listingcCsbt|dkr|d|t|\}}t|dkrL|ddtdd||D] }t|qPdS)NrrS cSsd|S)N-r&)xr&r&r'rQrRz.)leninserttabulatejoinmapr )r!rZr[Z pkg_stringssizesvalr&r&r'rVs    z*ListCommand.output_package_listing_columns)__name__ __module__ __qualname____doc__Zusagerr-r6r2r3r1r>r4rV __classcell__r&r&r$r'rs PrcCst|dkstdgtdd|D}|D]}ddt||D}q,g}|D](}dddt||D}||qN||fS)Nrcss|]}t|VqdSr@)r_r:r^r&r&r'rCsztabulate..cSs"g|]\}}t|tt|qSr&)maxr_strr:scr&r&r'r<sztabulate..r\cSs*g|]"\}}|dk r"t||ndqS)N)rmljustrnr&r&r'r<s)r_AssertionErrorrlrrbappend)ZvalsrdrowresultZdisplayr&r&r'ras  racCs|j}|rddddg}nddg}g}|jdks@tdd|DrJ|d|jdkr^|d |D]l}|j|jg}|r||j||j|jdkst|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/rWanyrtrKrIr8rMr rXr)Zpkgsr(Zrunning_outdatedr[rZZprojrur&r&r'rUs(         rUcCsvg}|D]b}|jt|jd}|jdkr@|j|d<t||d<|jr`t|j|d<|j |d<| |qt |S)N)namerIrSrXZ installerr8rM) rKrZ text_typerIrWrXrr/r8rMrtrdumps)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%