ó
äq™^c           @@  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 d  d l m Z d  d	 l m Z d  d
 l m Z d  d l m Z m Z m Z d  d l m Z e j e ƒ Z d e f d „  ƒ  YZ d „  Z d „  Z d „  Z  d S(   i    (   t   absolute_importN(   t   six(   t   zip_longest(   t
   cmdoptions(   t   IndexGroupCommand(   t   CommandError(   t   PackageFinder(   t   SelectionPreferences(   t   make_link_collector(   t   dist_is_editablet   get_installed_distributionst   write_output(   t   get_installert   ListCommandc           B@  se   e  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.
    s   
      %prog [options]c         O@  sÔ  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 t j ƒ  ƒ | j d d d d t d d ƒ| j d d d d d d d d d) d d ƒ| j d d d d d  d d! ƒ| j d" d d# d d$ d d% ƒ| j d& d d d d$ d d' d t ƒt j	 t j
 |  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   columnst   choicest   freezet   jsonsB   Select the output format among: columns (default), freeze, or jsons   --not-requiredt   not_requireds>   List packages that are not dependencies of installed packages.s   --exclude-editablet   store_falset   include_editables%   Exclude editable package from output.s   --include-editables%   Include editable package from output.i    (   R   R   R   (   t   superR   t   __init__t   cmd_optst
   add_optiont   FalseR   t	   list_patht   Truet   make_option_groupt   index_groupt   parsert   insert_option_group(   t   selft   argst   kwR   t
   index_opts(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyR   &   sz    						c         C@  s@   t  | d | ƒ} t d t d | j ƒ } t j d | d | ƒ S(   sK   
        Create a package finder appropriate to this list command.
        t   optionst   allow_yankedt   allow_all_prereleasest   link_collectort   selection_prefs(   R   R   R!   t   preR   t   create(   R(   R,   t   sessionR/   R0   (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyt   _build_package_finderv   s    	c         C@  sÒ   | j  r! | j r! t d ƒ ‚ n  t j | ƒ t d | j d | j d | j d | j	 d | j
 ƒ } | j r‚ |  j | | ƒ } n  | j  r  |  j | | ƒ } n | j r¾ |  j | | ƒ } n  |  j | | ƒ d  S(   Ns5   Options --outdated and --uptodate cannot be combined.t
   local_onlyt	   user_onlyt   editables_onlyt   include_editablest   paths(   t   outdatedt   uptodateR   R   t   check_list_path_optionR
   t   localR   t   editableR   t   pathR   t   get_not_requiredt   get_outdatedt   get_uptodatet   output_package_listing(   R(   R,   R)   t   packages(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyt   run‡   s"    							c         C@  s5   g  |  j  | | ƒ D] } | j | j k r | ^ q S(   N(   t   iter_packages_latest_infost   latest_versiont   parsed_version(   R(   RD   R,   t   dist(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyRA   ¤   s    c         C@  s5   g  |  j  | | ƒ D] } | j | j k r | ^ q S(   N(   RF   RG   RH   (   R(   RD   R,   RI   (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyRB   ª   s    c         @  sK   t  ƒ  ‰  x+ | D]# } ˆ  j d „  | j ƒ  Dƒ ƒ q W‡  f d †  | Dƒ S(   Nc         s@  s   |  ] } | j  Vq d  S(   N(   t   key(   t   .0t   requirement(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pys	   <genexpr>³   s    c         @  s%   h  |  ] } | j  ˆ  k r | ’ q S(    (   RJ   (   RK   t   pkg(   t   dep_keys(    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pys	   <setcomp>´   s   	 (   t   sett   updatet   requires(   R(   RD   R,   RI   (    (   RN   s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyR@   °   s    	!c         c@  sù   |  j  | ƒ ä } |  j | | ƒ } xÈ | D]À } d } | j | j ƒ } | j sz g  | D] } | j j sY | ^ qY } n  | j d | j ƒ }	 |	 j	 | ƒ }
 |
 d  k r° q+ n  |
 j } |
 j j rÎ d } n d } | | _ | | _ | Vq+ WWd  QXd  S(   Nt   unknownt   project_namet   wheelt   sdist(   t   _build_sessionR4   t   find_all_candidatesRJ   R1   t   versiont   is_prereleaset   make_candidate_evaluatorRS   t   sort_best_candidatet   Nonet   linkt   is_wheelRG   t   latest_filetype(   R(   RD   R,   R3   t   finderRI   t   typt   all_candidatest	   candidatet	   evaluatort   best_candidatet   remote_version(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyRF   ¶   s(    						c         C@  sâ   t  | d d „  ƒ} | j d k rR | rR t | | ƒ \ } } |  j | | ƒ nŒ | j d k r¹ xz | D]J } | j d k rœ t d | j | j | j ƒ qh t d | j | j ƒ qh Wn% | j d k rÞ t t	 | | ƒ ƒ n  d  S(	   NRJ   c         S@  s   |  j  j ƒ  S(   N(   RS   t   lower(   RI   (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyt   <lambda>Ö   s    R   R   i   s   %s==%s (%s)s   %s==%sR   (
   t   sortedR   t   format_for_columnst   output_package_listing_columnst   verboseR   RS   RX   t   locationt   format_for_json(   R(   RD   R,   t   datat   headerRI   (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyRC   Ó   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 | ƒ qx Wd  S(   Ni    i   t    c         S@  s   d |  S(   Nt   -(    (   t   x(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyRh   î   s    (   t   lent   insertt   tabulatet   joint   mapR   (   R(   Ro   Rp   t   pkg_stringst   sizest   val(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyRk   å   s    ((   t   __name__t
   __module__t   __doc__t   usageR   R4   RE   RA   RB   R@   RF   RC   Rk   (    (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyR      s   	P							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(   Rt   (   RK   Rs   (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pys	   <genexpr>ù   s    Rq   t    (	   Rt   t   AssertionErrort   maxR   t   strRw   R\   t   ljustt   append(   t   valsRz   t   rowt   st   ct   resultt   display(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyRv   ô   s    A	Ic         C@  s@  | j  } | r$ d d d d g } n d d g } g  } | j d k s[ t d „  |  Dƒ ƒ rk | j d ƒ n  | j d k rŠ | j d ƒ n  x© |  D]¡ } | j | j g } | rÒ | j | j ƒ | j | j ƒ n  | j d k sí t | ƒ r | j | j	 ƒ n  | j d k r%| j t
 | ƒ ƒ n  | j | ƒ q‘ W| | f S(	   s_   
    Convert the package data into something usable
    by output_package_listing_columns.
    t   Packaget   Versiont   Latestt   Typei   c         s@  s   |  ] } t  | ƒ Vq d  S(   N(   R	   (   RK   Rs   (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pys	   <genexpr>  s    t   Locationt	   Installer(   R:   Rl   t   anyR…   RS   RX   RG   R_   R	   Rm   R   (   t   pkgsR,   t   running_outdatedRp   Ro   t   projR‡   (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyRj     s(    	%c         C@  s²   g  } xœ |  D]” } i | j  d 6t j | j ƒ d 6} | j d k re | j | d <t | ƒ | d <n  | j r” t j | j ƒ | d <| j	 | d <n  | j
 | ƒ q Wt j | ƒ S(   Nt   nameRX   i   Rm   t	   installerRG   R_   (   RS   R   t	   text_typeRX   Rl   Rm   R   R:   RG   R_   R…   R   t   dumps(   RD   R,   Ro   RI   t   info(    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyRn   +  s    
	(!   t
   __future__R    R   t   loggingt   pip._vendorR   t   pip._vendor.six.movesR   t   pip._internal.cliR   t   pip._internal.cli.req_commandR   t   pip._internal.exceptionsR   t"   pip._internal.index.package_finderR   t$   pip._internal.models.selection_prefsR   t!   pip._internal.self_outdated_checkR   t   pip._internal.utils.miscR	   R
   R   t   pip._internal.utils.packagingR   t	   getLoggerR|   t   loggerR   Rv   Rj   Rn   (    (    (    s8   /tmp/pip-build-aSgKnK/pip/pip/_internal/commands/list.pyt   <module>   s"   Ø		%