σ
<Ύ^Yc           @@  s,  d  d l  m Z d  d l Z d  d l Z d  d l Z y d  d l m Z Wn! e k
 rk d  d l m Z n Xd  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 m Z e j e  Z d e f d     YZ d   Z d   Z d   Z d S(   i    (   t   absolute_importN(   t   zip_longest(   t   izip_longest(   t   six(   t   Command(   t   CommandError(   t   PackageFinder(   t   get_installed_distributionst   dist_is_editable(   t   RemovedInPip10Warning(   t   make_option_groupt   index_groupt   ListCommandc           B@  s   e  Z d  Z d Z d Z d Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z RS(   st   
    List installed packages, including editables.

    Packages are listed in a case-insensitive sorted order.
    t   lists   
      %prog [options]s   List installed packages.c         O@  sq  t  t |   j | |   |  j } | j d d d d d t d d | j d d	 d d d t d d
 | j d d d d d t d d | j d d d d d t d d |  j j d d d d d d t d d | j d d d d t d d | j d d d d d d d$ d d | j d  d d d d! d d" t t |  j  } |  j j	 d# |  |  j j	 d# |  d  S(%   Ns   -os
   --outdatedt   actiont
   store_truet   defaultt   helps   List outdated packagess   -us
   --uptodates   List uptodate packagess   -es
   --editables   List editable projects.s   -ls   --localsS   If in a virtualenv that has global access, do not list globally-installed packages.s   --usert   destt   users,   Only output packages installed in user-site.s   --presY   Include pre-release and development versions. By default, pip only finds stable versions.s   --formatt   storet   list_formatt   choicest   legacyt   columnst   freezet   jsonsJ   Select the output format among: legacy (default), columns, freeze or json.s   --not-requiredt   not_requireds>   List packages that are not dependencies of installed packages.i    (   s   legacys   columnss   freezes   json(
   t   superR   t   __init__t   cmd_optst
   add_optiont   FalseR
   R   t   parsert   insert_option_group(   t   selft   argst   kwR   t
   index_opts(    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyR   #   s^    						c         C@  s7   t  d | j d | d | j d | j d | j d |  S(   sK   
        Create a package finder appropriate to this list command.
        t
   find_linkst
   index_urlst   allow_all_prereleasest   trusted_hostst   process_dependency_linkst   session(   R   R'   t   preR*   R+   (   R#   t   optionsR(   R,   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyt   _build_package_finderc   s    				c         C@  s)  | j  r t j d t  n  | j r8 t j d t  n  | j rT t j d t  n  | j d  k rv t j d t  n  | j r | j	 r t
 d   n  t d | j d | j d | j  } | j rΩ |  j | |  } n | j	 rχ |  j | |  } n  | j r|  j | |  } n  |  j | |  d  S(	   Ns   --allow-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.s   --allow-all-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.s   --allow-unverified has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.sΗ   The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.s5   Options --outdated and --uptodate cannot be combined.t
   local_onlyt	   user_onlyt   editables_only(   t   allow_externalt   warningst   warnR	   t   allow_all_externalt   allow_unverifiedR   t   Nonet   outdatedt   uptodateR   R   t   localR   t   editablet   get_outdatedt   get_uptodateR   t   get_not_requiredt   output_package_listing(   R#   R.   R$   t   packages(    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyt   runp   s<    	
	
	

					c         C@  s5   g  |  j  | |  D] } | j | j k r | ^ q S(   N(   t   iter_packages_latest_infost   latest_versiont   parsed_version(   R#   RA   R.   t   dist(    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyR=   ¦   s    c         C@  s5   g  |  j  | |  D] } | j | j k r | ^ q S(   N(   RC   RD   RE   (   R#   RA   R.   RF   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyR>   ¬   s    c         @  sQ   t      x+ | D]# }   j d   | j   D  q Wt    f d   | D  S(   Nc         s@  s   |  ] } | j  Vq d  S(   N(   t   key(   t   .0t   requirement(    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pys	   <genexpr>΅   s    c         3@  s$   |  ] } | j    k r | Vq d  S(   N(   RG   (   RH   t   pkg(   t   dep_keys(    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pys	   <genexpr>Ά   s    (   t   sett   updatet   requires(   R#   RA   R.   RF   (    (   RK   s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyR?   ²   s    	!c      	   c@  sq  | j  g | j } | j r> t j d d j |   g  } n  g  } x6 | D]. } | j d  rK | j | j d   qK qK W|  j	 |  ί } |  j
 | | |  } | j |  x³ | D]« } d } | j | j  }	 | j sg  |	 D] }
 |
 j j sζ |
 ^ qζ }	 n  |	 sqΈ n  t |	 d | j } | j } | j j rFd } n d } | | _ | | _ | VqΈ WWd  QXd  S(   Ns   Ignoring indexes: %st   ,s   dependency_links.txtt   unknownRG   t   wheelt   sdist(   t	   index_urlt   extra_index_urlst   no_indext   loggert   debugt   joint   has_metadatat   extendt   get_metadata_linest   _build_sessionR/   t   add_dependency_linkst   find_all_candidatesRG   R-   t   versiont   is_prereleaset   maxt   _candidate_sort_keyt   locationt   is_wheelRD   t   latest_filetype(   R#   RA   R.   R(   t   dependency_linksRF   R,   t   findert   typt   all_candidatest	   candidatet   best_candidatet   remote_version(    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyRC   Έ   s:    								c         C@  s>   t  |  r& d | j | j | j f Sd | j | j f Sd  S(   Ns   %s (%s, %s)s   %s (%s)(   R   t   project_nameR_   Rc   (   R#   RF   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyt   output_legacyί   s    c         C@  s    d |  j  |  | j | j f S(   Ns   %s - Latest: %s [%s](   Rn   RD   Re   (   R#   RF   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyt   output_legacy_latestι   s    c         C@  s  t  | d d   } | j d k rR | rR t | |  \ } } |  j | |  n­ | j d k r x | D] } t j d | j | j  qh Wnq | j d k rΆ t j t | |   nI xF | D]> } | j	 rε t j |  j
 |   q½ t j |  j |   q½ Wd  S(   NRG   c         S@  s   |  j  j   S(   N(   Rm   t   lower(   RF   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyt   <lambda>σ   s    R   R   s   %s==%sR   (   t   sortedR   t   format_for_columnst   output_package_listing_columnsRV   t   infoRm   R_   t   format_for_jsonR9   Ro   Rn   (   R#   RA   R.   t   datat   headerRF   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyR@   π   s     	c         C@  s   t  |  d k r% | j d |  n  t |  \ } } t  |  d k rq | j d d j t d   |    n  x | D] } t j |  qx Wd  S(   Ni    i   t    c         S@  s   d |  S(   Nt   -(    (   t   x(    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyRq     s    (   t   lent   insertt   tabulateRX   t   mapRV   Ru   (   R#   Rw   Rx   t   pkg_stringst   sizest   val(    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyRt     s    ((   t   __name__t
   __module__t   __doc__t   namet   usaget   summaryR   R/   RB   R=   R>   R?   RC   Rn   Ro   R@   Rt   (    (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyR      s   	@		6				'	
		c         C@  s  t  |   d k s t  d g t d   |  D  } xK |  D]C } g  t | |  D]' \ } } t | t  t |    ^ qR } q< Wg  } xm |  D]e } d j g  t | |  D]3 \ } } | d  k	 rΩ t |  j |  n d ^ q¬  } | j |  q W| | f S(   Ni    c         s@  s   |  ] } t  |  Vq d  S(   N(   R|   (   RH   R{   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pys	   <genexpr>  s    Ry   t    (	   R|   t   AssertionErrorRa   R   t   strRX   R8   t   ljustt   append(   t   valsR   t   rowt   st   ct   resultt   display(    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyR~     s    A	Ic         C@  sή   | j  } | r$ d d d d g } n d d g } g  } t d   |  D  r\ | j d  n  xu |  D]m } | j | j g } | r€ | j | j  | j | j  n  t |  rΓ | j | j  n  | j |  qc W| | f S(   s_   
    Convert the package data into something usable
    by output_package_listing_columns.
    t   Packaget   Versiont   Latestt   Typec         s@  s   |  ] } t  |  Vq d  S(   N(   R   (   RH   R{   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pys	   <genexpr>2  s    t   Location(	   R9   t   anyR   Rm   R_   RD   Re   R   Rc   (   t   pkgsR.   t   running_outdatedRx   Rw   t   projR   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyRs   %  s     	c         C@  s   g  } xm |  D]e } i | j  d 6t j | j  d 6} | j re t j | j  | d <| j | d <n  | j |  q Wt j	 |  S(   NR   R_   RD   Re   (
   Rm   R   t	   text_typeR_   R9   RD   Re   R   R   t   dumps(   RA   R.   Rw   RF   Ru   (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyRv   F  s    
	(    t
   __future__R    R   t   loggingR4   t	   itertoolsR   t   ImportErrorR   t   pip._vendorR   t   pip.basecommandR   t   pip.exceptionsR   t	   pip.indexR   t	   pip.utilsR   R   t   pip.utils.deprecationR	   t   pip.cmdoptionsR
   R   t	   getLoggerR   RV   R   R~   Rs   Rv   (    (    (    s.   /tmp/pip-build-YOdFBd/pip/pip/commands/list.pyt   <module>   s&   ϋ		!