ķ
Š9Vc           @@  sŠ   d  d l  m Z d  d l m Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 m
 Z
 d  d l m Z e j e  Z d e f d     YZ d	   Z d
   Z d S(   i    (   t   absolute_import(   t
   FeedParserN(   t   Command(   t   SUCCESSt   ERROR(   t   pkg_resourcest   ShowCommandc           B@  s2   e  Z d  Z d Z d Z d Z d   Z d   Z RS(   s6   Show information about one or more installed packages.t   shows$   
      %prog [options] <package> ...s*   Show information about installed packages.c         O@  s^   t  t |   j | |   |  j j d d d d d d d t d d	 |  j j d
 |  j  d  S(   Ns   -fs   --filest   destt   filest   actiont
   store_truet   defaultt   helps7   Show the full list of installed files for each package.i    (   t   superR   t   __init__t   cmd_optst
   add_optiont   Falset   parsert   insert_option_group(   t   selft   argst   kw(    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/show.pyR      s    		c         C@  sC   | s t  j d  t S| } t |  } t | | j  s? t St S(   Ns.   ERROR: Please provide a package name or names.(   t   loggert   warningR   t   search_packages_infot   print_resultsR	   R   (   R   t   optionsR   t   queryt   results(    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/show.pyt   run!   s    (   t   __name__t
   __module__t   __doc__t   namet   usaget   summaryR   R   (    (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/show.pyR      s   	c         c@  sŌ  t  g  t j D] } | j j   | f ^ q  } g  |  D] } | j   ^ q8 } x{g  | D] } | | k rZ | | ^ qZ D]P} i | j d 6| j d 6| j d 6g  | j   D] } | j ^ qŽ d 6} d }	 d }
 t	 | t j
  rĻ| j d  r| j d  } g  | D] } | j d  d ^ q
} g  | D] } t j j | j |  ^ q0} g  | D] } t j j | | j  ^ q[}	 n  | j d  ri| j d  }
 qinÃ | j d	  r| j d	  } g  | D] } t j j | j |  ^ qË} g  | D] } t j j | | j  ^ qö}	 n  | j d
  rH| j d
  } | | d <n  | j d  ri| j d  }
 n  t   } | j |
  | j   } x! d D] } | j |  | | <qW|	 ožt |	  | d <| Vqz Wd S(   sî   
    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.
    R#   t   versiont   locationt   requirest   RECORDt   ,i    t   METADATAs   installed-files.txts   entry_points.txtt   entry_pointss   PKG-INFOs   metadata-versionR%   s	   home-paget   authors   author-emailt   licenseR	   N(   s   metadata-versions   summarys	   home-pages   authors   author-emails   license(   t   dictR   t   working_sett   project_namet   lowerR&   R'   R(   t   Nonet
   isinstancet   DistInfoDistributiont   has_metadatat   get_metadata_linest   splitt   ost   patht   joint   relpatht   get_metadatat   egg_infoR   t   feedt   closet   gett   sorted(   R   t   pt	   installedR#   t   query_namest   pkgt   distt   dept   packaget	   file_listt   metadatat   linest   lt   pathsR,   t   feed_parsert   pkg_info_dictt   key(    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/show.pyR   -   sH    .0


&&+.+.	
c         C@  sŅ  t  } xÄ|  D]ŧ} t } t j d  t j d | j d   t j d | d  t j d | d  t j d | j d	   t j d
 | j d   t j d | j d   t j d | j d   t j d | j d   t j d | d  t j d d j | d   | rt j d  | d d k	 rqx9 | d D] } t j d | j    qMWqt j d  n  d | k r t j d  x, | d D] } t j d | j    qĨWq q W| S(   sD   
    Print the informations from installed distributions found.
    s   ---s   Metadata-Version: %ss   metadata-versions   Name: %sR#   s   Version: %sR&   s   Summary: %sR%   s   Home-page: %ss	   home-pages
   Author: %sR-   s   Author-email: %ss   author-emails   License: %sR.   s   Location: %sR'   s   Requires: %ss   , R(   s   Files:R	   s     %ss!   Cannot locate installed-files.txtR,   s   Entry-points:N(   R   t   TrueR   t   infoRA   R;   R3   t   strip(   t   distributionst   list_all_filest   results_printedRG   t   line(    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/show.pyR   e   s2    "(   t
   __future__R    t   email.parserR   t   loggingR9   t   pip.basecommandR   t   pip.status_codesR   R   t   pip._vendorR   t	   getLoggerR    R   R   R   R   (    (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/show.pyt   <module>   s   	8