î
É X¾
  ã               @   sj   d  d l  Z  d  d l m Z d  d l m Z d  d l Z Gd d „  d e ƒ Z d d „  Z d d	 „  Z d S)
é    N)ÚCommand)Úloggerc                   sF   e  Z d  Z d Z d Z d Z d Z ‡  f d d †  Z d d „  Z ‡  S)	ÚShowCommandz6Show information about one or more installed packages.Úshowz$
      %prog [options] <package> ...z*Show information about installed packages.c                s^   t  t |  ƒ j | | Ž  |  j j d d d d d d d d d	 d
 ƒ|  j j d |  j ƒ d  S)Nz-fz--filesÚdestÚfilesÚactionÚ
store_trueÚdefaultFÚhelpz7Show the full list of installed files for each package.r   )Úsuperr   Ú__init__Úcmd_optsÚ
add_optionÚparserÚinsert_option_group)ÚselfÚargsÚkw)Ú	__class__© ú</home/ubuntu/projects/ifolica/build/pip/pip/commands/show.pyr      s    		zShowCommand.__init__c             C   s=   | s t  j d ƒ d  S| } t | ƒ } t | | j ƒ d  S)Nz.ERROR: Please provide a package name or names.)r   ÚwarnÚsearch_packages_infoÚprint_resultsr   )r   Úoptionsr   ÚqueryÚresultsr   r   r   Úrun   s    zShowCommand.run)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚusageÚsummaryr   r   r   r   )r   r   r      s   r   c             c   sÝ   t  d d „  t j Dƒ ƒ } xº |  D]² } | j ƒ  } | | k r# | | } i | j d 6| j d 6| j d 6d d „  | j ƒ  Dƒ d 6} t j	 j
 | j | j ƒ  d d	 ƒ } t j	 j | ƒ rÍ | | d
 <n  | Vq# q# Wd 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.
    c             S   s%   g  |  ] } | j  j ƒ  | f ‘ q Sr   )Úproject_nameÚlower)Ú.0Úpr   r   r   ú
<listcomp>,   s   	 z(search_packages_info.<locals>.<listcomp>r#   ÚversionÚlocationc             S   s   g  |  ] } | j  ‘ q Sr   )r&   )r(   Údepr   r   r   r*   5   s   	 Úrequiresz	.egg-infozinstalled-files.txtr   N)ÚdictÚpkg_resourcesÚworking_setr'   r&   r+   r,   r.   ÚosÚpathÚjoinÚegg_nameÚisfile)r   Úinstalled_packagesr#   Únormalized_nameÚdistÚpackageÚfilelistr   r   r   r   $   s$    



		r   c             C   sã   xÜ |  D]Ô } t  j d ƒ t  j d | d ƒ t  j d | d ƒ t  j d | d ƒ t  j d d	 j | d
 ƒ ƒ | r t  j d ƒ d | k rË x? t | d ƒ D] } t  j d | j ƒ  ƒ q§ WqÛ t  j d ƒ q q Wd S)zD
    Print the informations from installed distributions found.
    z---zName: %sr#   zVersion: %sr+   zLocation: %sr,   zRequires: %sz, r.   zFiles:r   z  %sz!Cannot locate installed-files.txtN)r   Únotifyr4   ÚopenÚstrip)ÚdistributionsÚlist_all_filesr9   Úliner   r   r   r   @   s    r   )	r2   Úpip.basecommandr   Úpip.logr   r0   r   r   r   r   r   r   r   Ú<module>   s   