o 7]h0 @sjddlZddlZddlmZddlmZmZmZmZm Z m Z m Z ddl m Z ddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZdd lm Z ddl!m"Z"ddl#m$Z$m%Z%erddl&m'Z'GdddeZ(e e(Z)ddl*m+Z+e,e-Z.GdddeZ/dddede eee0ee0ffddZ1dddede0fddZ2dS)N)Values) TYPE_CHECKINGIteratorListOptionalSequenceTuplecastcanonicalize_name) cmdoptions)IndexGroupCommand)SUCCESS) CommandError) LinkCollector) PackageFinder)BaseDistributionget_environment)SelectionPreferences) PipSession) stdlib_pkgs)tabulate write_output)DistributionVersionc@s"eZdZUdZeed<eed<dS)_DistWithLatestInfozGive 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. latest_versionlatest_filetypeN)__name__ __module__ __qualname____doc__r__annotations__strr#r#=/usr/lib/python3/dist-packages/pip/_internal/commands/list.pyrs  r)parsec@seZdZdZdZdZd ddZded ede fd d Z ded e e de fd dZdddeddfddZdddeddfddZdddeddfddZdddededfddZdddeddfddZde e e de e ddfddZdS)! ListCommandzt List installed packages, including editables. Packages are listed in a case-insensitive sorted order. Tz %prog [options]returnNcCs*|jjdddddd|jjddddd d|jjd d ddd d|jjd ddddd|jjdddddd|jt|jjddddd|jjddddddd|jjddddd |jjd!d"d#d$d |jjd%dd#d&d'd(|jtttj|j}|jd)||jd)|jdS)*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.)destr)r*r+z--prezYInclude pre-release and development versions. By default, pip only finds stable versions.z--formatstore list_formatcolumns)r0freezejsonzBSelect the output format among: columns (default), freeze, or json)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_falseinclude_editablez%Exclude editable package from output.z--include-editablez%Include editable package from output.T)r)r-r+r*r) cmd_opts add_optionr list_path list_excludemake_option_group index_groupparserinsert_option_group)self index_optsr#r#r$ add_options4s   zListCommand.add_optionsoptionssessioncCs2tj||d}td|jd}tj||d|jvdS)zK Create a package finder appropriate to this list command. )rBF) allow_yankedallow_all_prereleaseshtml5lib)link_collectorselection_prefsuse_deprecated_html5lib)rcreaterprerdeprecated_features_enabled)r?rBrCrGrHr#r#r$_build_package_findersz!ListCommand._build_package_finderargscCs|jr |jr tdt|tt}|jr!|dd|jDddt |j j |j |j |j|j|dD}|jr@|||}|jrJ|||}n |jrS|||}|||tS)Nz5Options --outdated and --uptodate cannot be combined.css|]}t|VqdSNr ).0nr#r#r$ sz"ListCommand.run..cSsg|]}td|qS)r)r )rPdr#r#r$ sz#ListCommand.run..) local_only user_onlyeditables_onlyinclude_editablesskip)outdateduptodaterr check_list_path_optionsetrexcludesupdaterpathiter_installed_distributionslocalr,editabler6r4get_not_required get_outdated get_uptodateoutput_package_listingr)r?rBrNrYpackagesr#r#r$runs.      zListCommand.runrh_ProcessedDistscCdd|||DS)NcSs,g|]}tt|jtt|jkr|qSr#r%r"rversionrPdistr#r#r$rT z,ListCommand.get_outdated..iter_packages_latest_infosr?rhrBr#r#r$re zListCommand.get_outdatedcCrk)NcSs,g|]}tt|jtt|jkr|qSr#rlrnr#r#r$rTrpz,ListCommand.get_uptodate..rqrsr#r#r$rfrtzListCommand.get_uptodatecs$dd|Dtfdd|DS)NcSs(h|]}|p dD]}t|jq qS)r#)iter_dependenciesr name)rProdepr#r#r$ s z/ListCommand.get_not_required..csh|] }|jvr|qSr#canonical_name)rPpkgdep_keysr#r$rxs)listrsr#r|r$rds zListCommand.get_not_requiredrc#sx|,}||dddtdffdd }t||D] }|dur)|Vq WddS1s5wYdS)Nrorr'csl|j}jsdd|D}j|jd}||}|dur"dS|j}|jjr,d}nd}||_||_ |S)NcSsg|]}|jjs|qSr#)rm is_prerelease)rP candidater#r#r$rTs zOListCommand.iter_packages_latest_infos..latest_info..) project_namewheelsdist) find_all_candidatesrzrKmake_candidate_evaluatorsort_best_candidatermlinkis_wheelrr)roall_candidates evaluatorbest_candidateremote_versiontypfinderrBr#r$ latest_infos$  z;ListCommand.iter_packages_latest_infos..latest_info)_build_sessionrMrmap)r?rhrBrCrror#rr$rrs  "z&ListCommand.iter_packages_latest_infoscCst|ddd}|jdkr|rt||\}}|||dS|jdkrB|D]}|jdkr7td|j|j|jq%td|j|jq%dS|jd krPtt ||dSdS) NcSs|jSrOry)ror#r#r$ sz4ListCommand.output_package_listing..)keyr0r1z %s==%s (%s)z%s==%sr2) sortedr/format_for_columnsoutput_package_listing_columnsverboserraw_namermlocationformat_for_json)r?rhrBdataheaderror#r#r$rgs$   z"ListCommand.output_package_listingrrcCsbt|dkr |d|t|\}}t|dkr&|ddtdd||D]}t|q(dS)Nrr cSsd|S)N-r#)xr#r#r$r'sz.)leninsertrjoinrr)r?rr pkg_stringssizesvalr#r#r$rs     z*ListCommand.output_package_listing_columns)r'N)rrrr ignore_require_venvusagerArrrrMrr"intrirerfrdrrrrgrr#r#r#r$r&)sn U $      &  r&pkgsrjrBr'cCsddg}|j}|r|ddgtdd|D}|r |d|jdkr*|d |jdkr4|d g}|D]A}|jt|jg}|rR|t|j||j |r\||j pZd |jdkri||j pgd |jdkrt||j ||q8||fS) z_ Convert the package data into something usable by output_package_listing_columns. PackageVersionLatestTypecss|]}|jVqdSrO)rc)rPrr#r#r$rR:sz%format_for_columns..zEditable project locationrLocation Installer) rZextendanyappendrrr"rmrreditable_project_locationr installer)rrBrrunning_outdated has_editablesrprojrowr#r#r$r-s2          rrhcCsg}|D]9}|jt|jd}|jdkr |jpd|d<|j|d<|jr/t|j|d<|j|d<|j }|r8||d<| |qt |S) N)rvrmrrrrrrr) rr"rmrrrrZrrrrr2dumps)rhrBrroinforr#r#r$rZs      r)3r2loggingoptparsertypingrrrrrrr pip._vendor.packaging.utilsr pip._internal.clir pip._internal.cli.req_commandr pip._internal.cli.status_codesrpip._internal.exceptionsrpip._internal.index.collectorr"pip._internal.index.package_finderrpip._internal.metadatarr$pip._internal.models.selection_prefsrpip._internal.network.sessionrpip._internal.utils.compatrpip._internal.utils.miscrrpip._internal.metadata.baserrrjpip._vendor.packaging.versionr% getLoggerrloggerr&r"rrr#r#r#r$sB $              -