3 Pfi, @sddlmZddlZddlZddlZyddlmZWn ek rTddlmZYnXddl m Z ddl m Z ddl mZddlmZdd lmZmZdd lmZdd lmZmZejeZGd d d e ZddZddZddZdS))absolute_importN) zip_longest) izip_longest)six)Command) CommandError) PackageFinder)get_installed_distributionsdist_is_editable)RemovedInPip10Warning)make_option_group index_groupcs|eZdZdZdZdZdZfddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZddZZS) ListCommandzt List installed packages, including editables. Packages are listed in a case-insensitive sorted order. listz %prog [options]zList installed packages.cstt|j|||j}|jdddddd|jddddd d|jd d ddd d|jd ddddd|jjdddddd|jddddd|jdddd$dd|jddd d!d"tt|j}|jjd#||jjd#|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_formatlegacycolumnsfreezejsonzJSelect the output format among: legacy (default), columns, freeze or json.)rrchoicesrz--not-required not_requiredz>List packages that are not dependencies of installed packages.)rrrr)rrrr) superr__init__cmd_optsZ add_optionr r parserZinsert_option_group)selfargskwrZ index_opts) __class__/usr/lib/python3.6/list.pyr#s^ zListCommand.__init__cCst|j||j|j|j|dS)zK Create a package finder appropriate to this list command. ) find_links index_urlsZallow_all_prereleases trusted_hostsprocess_dependency_linkssession)rr'prer)r*)r!optionsr(r+r%r%r&_build_package_findercsz!ListCommand._build_package_findercCs|jrtjdt|jr$tjdt|jr6tjdt|jdkrLtjdt|jr`|jr`t dt |j |j |j d}|jr|j||}n|jr|j||}|jr|j||}|j||dS)Nz--allow-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.z--allow-all-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.z--allow-unverified has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.zThe default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.z5Options --outdated and --uptodate cannot be combined.)Z local_onlyZ user_onlyZeditables_only)Zallow_externalwarningswarnr Zallow_all_externalZallow_unverifiedroutdatedZuptodaterr ZlocalrZeditable get_outdated get_uptodaterget_not_requiredoutput_package_listing)r!r-r"packagesr%r%r&runps<     zListCommand.runcCsdd|j||DS)NcSsg|]}|j|jkr|qSr%)latest_versionparsed_version).0distr%r%r& sz,ListCommand.get_outdated..)iter_packages_latest_infos)r!r6r-r%r%r&r2szListCommand.get_outdatedcCsdd|j||DS)NcSsg|]}|j|jkr|qSr%)r8r9)r:r;r%r%r&r<sz,ListCommand.get_uptodate..)r=)r!r6r-r%r%r&r3szListCommand.get_uptodatecsBtx$|D]}jdd|jDq Wtfdd|DS)Ncss|] }|jVqdS)N)key)r:Z requirementr%r%r& sz/ListCommand.get_not_required..c3s|]}|jkr|VqdS)N)r>)r:Zpkg)dep_keysr%r&r?s)setupdateZrequires)r!r6r-r;r%)r@r&r4s zListCommand.get_not_requiredc cs|jg|j}|jr*tjddj|g}g}x&|D]}|jdr4|j|jdq4W|j |}|j |||}|j |xn|D]f}d}|j |j } |jsdd| D} | sqt| |jd} | j} | jjrd}nd }| |_||_|VqWWdQRXdS) NzIgnoring indexes: %s,zdependency_links.txtunknowncSsg|]}|jjs|qSr%)versionZ is_prerelease)r: candidater%r%r&r<sz:ListCommand.iter_packages_latest_infos..)r>ZwheelZsdist)Z index_urlZextra_index_urlsZno_indexloggerdebugjoinZ has_metadataextendZget_metadata_linesZ_build_sessionr.Zadd_dependency_linksZfind_all_candidatesr>r,maxZ_candidate_sort_keyrElocationZis_wheelr8latest_filetype) r!r6r-r(Zdependency_linksr;r+findertypZall_candidatesZbest_candidateZremote_versionr%r%r&r=s8       z&ListCommand.iter_packages_latest_infoscCs0t|rd|j|j|jfSd|j|jfSdS)Nz %s (%s, %s)z%s (%s))r project_namerErL)r!r;r%r%r& output_legacys  zListCommand.output_legacycCsd|j||j|jfS)Nz%s - Latest: %s [%s])rQr8rM)r!r;r%r%r&output_legacy_latestsz ListCommand.output_legacy_latestcCst|ddd}|jdkr:|r:t||\}}|j||n~|jdkrfxr|D]}tjd|j|jqJWnR|jdkrtjt||n6x4|D],}|j rtj|j |qtj|j |qWdS)NcSs |jjS)N)rPlower)r;r%r%r&sz4ListCommand.output_package_listing..)r>rrz%s==%sr) sortedrformat_for_columnsoutput_package_listing_columnsrGinforPrEformat_for_jsonr1rRrQ)r!r6r-dataheaderr;r%r%r&r5s     z"ListCommand.output_package_listingcCsht|dkr|jd|t|\}}t|dkrL|jddjtdd|x|D]}tj|qRWdS)Nr cSsd|S)N-r%)xr%r%r&rT sz.)leninserttabulaterImaprGrX)r!rZr[Z pkg_stringssizesvalr%r%r&rWs     z*ListCommand.output_package_listing_columns)__name__ __module__ __qualname____doc__nameZusageZsummaryrr.r7r2r3r4r=rQrRr5rW __classcell__r%r%)r$r&rs @ 6' rcCsxdgtdd|D}x |D]}ddt||D}qWg}x0|D](}djddt||D}|j|qDW||fS)Nrcss|]}t|VqdS)N)r`)r:r_r%r%r&r?sztabulate..cSs"g|]\}}t|tt|qSr%)rKr`str)r:scr%r%r&r<sztabulate..r]cSs*g|]"\}}|dk r"t|j|ndqS)N)rlljust)r:rmrnr%r%r&r<s)rKrrIappend)valsrdrowresultZdisplayr%r%r&rbs   rbcCs|j}|rddddg}nddg}g}tdd|Dr@|jdxR|D]J}|j|jg}|rr|j|j|j|jt|r|j|j|j|qFW||fS)z_ Convert the package data into something usable by output_package_listing_columns. ZPackageZVersionZLatestZTypecss|]}t|VqdS)N)r )r:r_r%r%r&r?2sz%format_for_columns..ZLocation) r1anyrqrPrEr8rMr rL)Zpkgsr-Zrunning_outdatedr[rZZprojrsr%r%r&rV%s       rVcCsZg}xJ|D]B}|jtj|jd}|jrBtj|j|d<|j|d<|j|q Wtj |S)N)rjrEr8rM) rPrZ text_typerEr1r8rMrqrdumps)r6r-rZr;rXr%r%r&rYFs  rY) Z __future__rrZloggingr/ itertoolsr ImportErrorrZ pip._vendorrZpip.basecommandrZpip.exceptionsrZ pip.indexrZ pip.utilsr r Zpip.utils.deprecationr Zpip.cmdoptionsr r Z getLoggerrfrGrrbrVrYr%r%r%r&s(       |!