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 PrcCs€t|ƒdkst‚dgtdd„|Dƒƒ}|D]}dd„t||ƒDƒ}q,g}|D](}d dd„t||ƒDƒ¡}| |¡qN||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ÿ)r_ÚAssertionErrorrlrrbÚ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ÚanyrtrKrIr8rMr rXr)Zpkgsr(Zrunning_outdatedr[rZZprojrur&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/r8rMrtrÚ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%