ó
Ð²Ebc           @@  s  d  d l  m Z d  d l Z d  d l Z d  d l m Z d  d l m Z d  d l m	 Z	 d  d l
 m Z d  d l m Z m Z d  d l m Z d  d	 l m Z e rÓ d  d
 l m Z d  d l m Z m Z m Z n  e j e ƒ Z d e f d „  ƒ  YZ d „  Z e e d „ Z d S(   i    (   t   absolute_importN(   t
   FeedParser(   t   pkg_resources(   t   canonicalize_name(   t   Command(   t   ERRORt   SUCCESS(   t   write_output(   t   MYPY_CHECK_RUNNING(   t   Values(   t   Dictt   Iteratort   Listt   ShowCommandc           B@  s,   e  Z d  Z d Z e Z d „  Z d „  Z RS(   sx   
    Show information about one or more installed packages.

    The output is in RFC-compliant mail header format.
    s$   
      %prog [options] <package> ...c         C@  sE   |  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   cmd_optst
   add_optiont   Falset   parsert   insert_option_group(   t   self(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/show.pyt   add_options!   s    		c         C@  sO   | s t  j d ƒ t S| } t | ƒ } t | d | j d | j ƒsK t St S(   Ns.   ERROR: Please provide a package name or names.t
   list_filest   verbose(   t   loggert   warningR   t   search_packages_infot   print_resultsR   R   R   (   R   t   optionst   argst   queryt   results(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/show.pyt   run,   s    (   t   __name__t
   __module__t   __doc__t   usaget   Truet   ignore_require_venvR   R%   (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/show.pyR      s
   	c         c@  sâ  i  } x$ t  j D] } | | t | j ƒ <q Wg  |  D] } t | ƒ ^ q4 } t g  t |  | ƒ D] \ } } | | k r_ | ^ q_ ƒ } | r¨ t j d d j | ƒ ƒ n  d „  } x*g  | D] } | | k r» | | ^ q» D]ÿ} i | j d 6| j	 d 6| j
 d 6g  | j ƒ  D] }	 |	 j ^ qd 6| | j ƒ 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
 | ƒ ^ q¡} g  | D] } t j j | | j
 ƒ ^ qÌ} n  | j d ƒ r¯| j d ƒ } q¯n˜ | j d ƒ rŽ| j d ƒ } g  | D] } t j j | j | ƒ ^ q<} g  | D] } t j j | | j
 ƒ ^ qg} n  | j d ƒ r¯| j d ƒ } n  | j d ƒ rÚ| j d ƒ } | |
 d <n  | j d ƒ r&x: | j d ƒ D]& } | j ƒ  rù| j ƒ  |
 d <PqùqùWn  t ƒ  } | j | ƒ | j ƒ  } x! d D] } | j | ƒ |
 | <qOWg  } x= | j ƒ  D]/ } | j d ƒ r| j | t d ƒ ƒ qqW| |
 d <| rÕt | ƒ |
 d <n  |
 VqÛ 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.
    s   Package(s) not found: %ss   , c         S@  sW   t  |  ƒ } g  t j D]= } | g  | j ƒ  D] } t  | j ƒ ^ q, k r | j ^ q S(   N(   R   R   t   working_sett   requirest   namet   project_name(   t   package_namet   canonical_namet   pkgt   required(    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/show.pyt   get_requiring_packagesM   s
    R.   t   versiont   locationR-   t   required_byt    t   RECORDt   ,i    t   METADATAs   installed-files.txts   PKG-INFOs   entry_points.txtt   entry_pointst	   INSTALLERt	   installers   metadata-versiont   summarys	   home-paget   authors   author-emailt   licenses   Classifier: t   classifiersR   N(   s   metadata-versionR?   s	   home-pageR@   s   author-emailRA   (    R   R,   R   R/   t   sortedt   zipR   R   t   joinR5   R6   R-   t   Nonet
   isinstancet   DistInfoDistributiont   has_metadatat   get_metadata_linest   splitt   ost   patht   relpatht   get_metadatat   egg_infot   stripR   t   feedt   closet   gett
   splitlinest
   startswitht   appendt   len(   R#   t	   installedt   pR.   t   query_namesR2   t   missingR4   t   distt   dept   packaget	   file_listt   metadatat   linest   linet   pathsR<   t   feed_parsert   pkg_info_dictt   keyRB   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/show.pyR   :   sl    7	
0


#&+.+.	

c   	      C@  sW  t  } xJt |  ƒ D]<\ } } t } | d k r> t d ƒ n  t d | j d d ƒ ƒ t d | j d d ƒ ƒ t d | j d	 d ƒ ƒ t d
 | j d d ƒ ƒ t d | j d d ƒ ƒ t d | j d d ƒ ƒ t d | j d d ƒ ƒ t d | j d d ƒ ƒ t d d j | j d g  ƒ ƒ ƒ t d d j | j d g  ƒ ƒ ƒ | rót d | j d d ƒ ƒ t d | j d d ƒ ƒ t d ƒ x' | j d g  ƒ D] } t d | ƒ qŸWt d  ƒ x0 | j d! g  ƒ D] } t d | j ƒ  ƒ qÓWn  | r t d" ƒ x- | j d# g  ƒ D] } t d | j ƒ  ƒ qWd# | k rOt d$ ƒ qOq q W| S(%   sC   
    Print the information from installed distributions found.
    i    s   ---s   Name: %sR.   R8   s   Version: %sR5   s   Summary: %sR?   s   Home-page: %ss	   home-pages
   Author: %sR@   s   Author-email: %ss   author-emails   License: %sRA   s   Location: %sR6   s   Requires: %ss   , R-   s   Required-by: %sR7   s   Metadata-Version: %ss   metadata-versions   Installer: %sR>   s   Classifiers:RB   s     %ss   Entry-points:R<   s   Files:R   s!   Cannot locate installed-files.txt(   R   t	   enumerateR*   R   RT   RE   RQ   (	   t   distributionsR   R   t   results_printedt   iR]   t
   classifiert   entryRc   (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/show.pyR    ”   s@    ""


(    t
   __future__R    t   loggingRL   t   email.parserR   t   pip._vendorR   t   pip._vendor.packaging.utilsR   t   pip._internal.cli.base_commandR   t   pip._internal.cli.status_codesR   R   t   pip._internal.utils.miscR   t   pip._internal.utils.typingR   t   optparseR	   t   typingR
   R   R   t	   getLoggerR&   R   R   R   R   R    (    (    (    s8   /tmp/pip-build-UPPWic/pip/pip/_internal/commands/show.pyt   <module>   s    $	Z