3

Q'ícã@sŒddlmZddlmZddlZddlZddlmZddlm	Z	m
Z
ddlmZddl
mZejeƒZGdd	„d	eƒZd
d„Zdd
d„ZdS)é)Úabsolute_import)Ú
FeedParserN)ÚCommand)ÚSUCCESSÚERROR)Ú
pkg_resources)Úcanonicalize_namecs4eZdZdZdZdZdZ‡fdd„Zdd„Z‡Z	S)	ÚShowCommandz6Show information about one or more installed packages.Úshowz$
      %prog [options] <package> ...z*Show information about installed packages.cs>tt|ƒj||Ž|jjddddddd|jjd|jƒdS)	Nz-fz--filesÚfilesÚ
store_trueFz7Show the full list of installed files for each package.)ÚdestÚactionÚdefaultÚhelpr)Úsuperr	Ú__init__Úcmd_optsÚ
add_optionÚparserÚinsert_option_group)ÚselfÚargsÚkw)Ú	__class__©ú0/tmp/pip-build-l_bcah40/pip/pip/commands/show.pyrszShowCommand.__init__cCs8|stjdƒtS|}t|ƒ}t||j|jds4tStS)Nz.ERROR: Please provide a package name or names.)Ú
list_filesÚverbose)ÚloggerÚwarningrÚsearch_packages_infoÚ
print_resultsrrr)rÚoptionsrÚqueryÚresultsrrrÚrun"s
zShowCommand.run)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚusageÚsummaryrr&Ú
__classcell__rr)rrr	sr	c#si‰xtjD]}|ˆt|jƒ<qWdd„|Dƒ}xæ‡fdd„|DƒD]Ήˆjˆjˆjdd„ˆjƒDƒdœ}d}d}tˆtjƒrވj	dƒrȈj
dƒ}dd„|Dƒ}‡fd	d„|Dƒ}‡fd
d„|Dƒ}ˆj	dƒr܈jdƒ}nPˆj	dƒrˆj
dƒ}‡fd
d„|Dƒ}‡fdd„|Dƒ}ˆj	dƒr.ˆjdƒ}ˆj	dƒrLˆj
dƒ}||d<ˆj	dƒr†x,ˆj
dƒD]}	|	jƒrd|	jƒ|d<PqdWt
ƒ}
|
j|ƒ|
jƒ}xdD]}|j|ƒ||<q¤Wg}
x4|jƒD](}	|	jdƒrÊ|
j|	tdƒd…ƒqÊW|
|d<|rt|ƒ|d<|VqFWdS)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|ƒ‘qSr)r)Ú.0r+rrrú
<listcomp>:sz(search_packages_info.<locals>.<listcomp>csg|]}|ˆkrˆ|‘qSrr)r/Úpkg)Ú	installedrrr0<scSsg|]
}|j‘qSr)Úproject_name)r/Údeprrrr0As)r+ÚversionÚlocationÚrequiresNÚRECORDcSsg|]}|jdƒd‘qS)ú,r)Úsplit)r/Úlrrrr0Iscsg|]}tjjˆj|ƒ‘qSr)ÚosÚpathÚjoinr6)r/Úp)Údistrrr0Jscsg|]}tjj|ˆjƒ‘qSr)r<r=Úrelpathr6)r/r?)r@rrr0KsÚMETADATAzinstalled-files.txtcsg|]}tjjˆj|ƒ‘qSr)r<r=r>Úegg_info)r/r?)r@rrr0Sscsg|]}tjj|ˆjƒ‘qSr)r<r=rAr6)r/r?)r@rrr0TszPKG-INFOzentry_points.txtÚentry_pointsÚ	INSTALLERÚ	installerúmetadata-versionr-ú	home-pageÚauthorúauthor-emailÚlicensezClassifier: Úclassifiersr)rGr-rHrIrJrK)rÚworking_setrr3r5r6r7Ú
isinstanceÚDistInfoDistributionÚhas_metadataÚget_metadata_linesÚget_metadataÚstriprÚfeedÚcloseÚgetÚ
splitlinesÚ
startswithÚappendÚlenÚsorted)r$r?Úquery_namesÚpackageÚ	file_listÚmetadataÚlinesÚpathsrDÚlineÚfeed_parserÚ
pkg_info_dictÚkeyrLr)r@r2rr!/s^







r!Fc	CsÈd}x¼t|ƒD]®\}}d}|dkr0tjdƒtjd|jddƒƒtjd|jd	dƒƒtjd
|jddƒƒtjd|jd
dƒƒtjd|jddƒƒtjd|jddƒƒtjd|jddƒƒtjd|jddƒƒtjddj|jdgƒƒƒ|rxtjd|jddƒƒtjd|jddƒƒtjdƒx"|jdgƒD]}tjd|ƒq0Wtjd ƒx&|jd!gƒD]}tjd|jƒƒq^W|rtjd"ƒx&|jd#gƒD]}tjd|jƒƒq”Wd#|krtjd$ƒqW|S)%zD
    Print the informations from installed distributions found.
    FTrz---zName: %sr+ÚzVersion: %sr5zSummary: %sr-z
Home-page: %sz	home-pagez
Author: %srIzAuthor-email: %szauthor-emailzLicense: %srKzLocation: %sr6zRequires: %sz, r7zMetadata-Version: %szmetadata-versionz
Installer: %srFzClassifiers:rLz  %sz
Entry-points:rDzFiles:rz!Cannot locate installed-files.txt)Ú	enumeraterÚinforVr>rS)	Ú
distributionsrrÚresults_printedÚir@Ú
classifierÚentryrbrrrr"xs>



r")FF)Ú
__future__rÚemail.parserrÚloggingr<Úpip.basecommandrÚpip.status_codesrrÚpip._vendorrÚpip._vendor.packaging.utilsrÚ	getLoggerr'rr	r!r"rrrrÚ<module>s
I