U .e@sddlmZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z mZddlmZeeZGd d d e Zd d ZdddZdS))absolute_importN) FeedParser) pkg_resourcescanonicalize_name)Command)ERRORSUCCESS) write_outputcs0eZdZdZdZdZfddZddZZS) ShowCommandzx Show information about one or more installed packages. The output is in RFC-compliant mail header format. z$ %prog [options] ...Tcs>tt|j|||jjddddddd|jd|jdS) Nz-fz--filesfiles store_trueFz7Show the full list of installed files for each package.)destactiondefaulthelpr)superr __init__Zcmd_optsZ add_optionparserZinsert_option_group)selfargskw __class__?/usr/lib/python3.8/site-packages/pip/_internal/commands/show.pyrszShowCommand.__init__cCs8|stdtS|}t|}t||j|jds4tStS)Nz.ERROR: Please provide a package name or names.) list_filesverbose)loggerwarningrsearch_packages_info print_resultsr rr )rZoptionsrqueryresultsrrrrun*s zShowCommand.run) __name__ __module__ __qualname____doc__ZusageZignore_require_venvrr$ __classcell__rrrrr s  r c#sTitjD]}|t|j<q dd|D}tfddt||D}|r^tdd|dd}fdd|DD]ԉjj j d d D|jd }d }d }t tj rd rd }d d|D} fdd| D} fdd| D}drnd}nPdrXd} fdd| D} fdd| D}drnd}drd} | |d<drƈdD]"} | r| |d<qƐqt} | || } dD]}| |||<qg}|D](} | dr|| tdd q||d<|rHt||d<|Vqxd S)z Gather details from installed distributions. Print distribution name, version, location, and installed files. Installed files requires a pip generated 'installed-files.txt' in the distributions '.egg-info' directory. cSsg|] }t|qSrr).0namerrr Bsz(search_packages_info..csg|]\}}|kr|qSrr)r*r+pkg installedrrr,DszPackage(s) not found: %s, cst|fddtjDS)Ncs(g|] }dd|Dkr|jqS)cSsg|]}t|jqSr)rr+)r*Zrequiredrrrr,NszSsearch_packages_info..get_requiring_packages...)requires project_namer*r-Zcanonical_namerrr,KszHsearch_packages_info..get_requiring_packages..)rr working_set)Z package_namerr4rget_requiring_packagesIs z4search_packages_info..get_requiring_packagescsg|]}|kr|qSrrr3r.rrr,RscSsg|] }|jqSr)r2)r*Zdeprrrr,Ws)r+versionlocationr1 required_byNZRECORDcSsg|]}|ddqS),r)split)r*lrrrr,`scsg|]}tjj|qSr)ospathjoinr8r*pdistrrr,ascsg|]}tj|jqSrr=r>relpathr8r@rBrrr,bsZMETADATAzinstalled-files.txtcsg|]}tjj|qSr)r=r>r?Zegg_infor@rBrrr,jscsg|]}tj|jqSrrDr@rBrrr,kszPKG-INFOzentry_points.txt entry_pointsZ INSTALLER installer)metadata-versionsummary home-pageauthor author-emaillicensez Classifier: classifiersr )rr5rr2sortedziprrr?r7r8r1 isinstanceZDistInfoDistributionZ has_metadataZget_metadata_linesZ get_metadatastriprZfeedcloseget splitlines startswithappendlen)r"rAZ query_namesZmissingr6packageZ file_listZmetadatalinespathsrFlineZ feed_parserZ pkg_info_dictkeyrNr)rCr/rr 7sl                    r Fc Csd}t|D]\}}d}|dkr*tdtd|ddtd|d dtd |d dtd |d dtd|ddtd|ddtd|ddtd|ddtdd|dgtdd|dg|rdtd|ddtd|ddtd|d gD]}td!|q(td"|d#gD]}td!|qN|r td$|d%gD]}td!|q|d%|kr td&q |S)'zD Print the informations from installed distributions found. FTrz---zName: %sr+z Version: %sr7z Summary: %srIz Home-page: %srJz Author: %srKzAuthor-email: %srLz License: %srMz Location: %sr8z Requires: %sr0r1zRequired-by: %sr9zMetadata-Version: %srHz Installer: %srGz Classifiers:rNz %sz Entry-points:rFzFiles:r z!Cannot locate installed-files.txt) enumerater rTr?rR) Z distributionsrrZresults_printedirCZ classifierentryr\rrrr!sB  r!)FF)Z __future__rZloggingr=Z email.parserrZ pip._vendorrZpip._vendor.packaging.utilsrZpip._internal.cli.base_commandrZpip._internal.cli.status_codesrr Zpip._internal.utils.miscr Z getLoggerr%rr r r!rrrrs       #X