ó
ä™L]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 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   Command(   t   make_search_scope(   t   CommandError(   t   PackageFinder(   t   SelectionPreferences(   t   dist_is_editablet   get_installed_distributions(   t   get_installert   ListCommandc           B@  sq   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 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@  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-sZz8gW/pip/pip/_internal/commands/list.pyR   "   sz    						c      	   C@  sI   t  | ƒ } t d t d | j ƒ } t j d | d | d | j d | ƒ S(   sK   
        Create a package finder appropriate to this list command.
        t   allow_yankedt   allow_all_prereleasest   search_scopet   selection_prefst   trusted_hostst   session(   R   R   R!   t   preR   t   createR0   (   R(   t   optionsR1   R.   R/   (    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyt   _build_package_finderr   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(   R4   R)   t   packages(    (    s8   /tmp/pip-build-sZz8gW/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(   RE   R4   t   dist(    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRB   ¢   s    c         C@  s5   g  |  j  | | ƒ D] } | j | j k r | ^ q S(   N(   RG   RH   RI   (   R(   RE   R4   RJ   (    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRC   ¨   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-sZz8gW/pip/pip/_internal/commands/list.pys	   <genexpr>±   s    c         @  s%   h  |  ] } | j  ˆ  k r | ’ q S(    (   RK   (   RL   t   pkg(   t   dep_keys(    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pys	   <setcomp>²   s   	 (   t   sett   updatet   requires(   R(   RE   R4   RJ   (    (   RO   s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRA   ®   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_sessionR5   t   find_all_candidatesRK   R2   t   versiont   is_prereleaset   make_candidate_evaluatorRT   t   get_best_candidatet   Nonet   linkt   is_wheelRH   t   latest_filetype(   R(   RE   R4   R1   t   finderRJ   t   typt   all_candidatest	   candidatet	   evaluatort   best_candidatet   remote_version(    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRG   ´   s(    						c         C@  së   t  | d d „  ƒ} | j d k rR | rR t | | ƒ \ } } |  j | | ƒ n• | j d k r¿ xƒ | D]P } | j d k rŸ t j d | j | j | j	 ƒ qh t j d | j | j ƒ qh Wn( | j d k rç t j t
 | | ƒ ƒ n  d  S(	   NRK   c         S@  s   |  j  j ƒ  S(   N(   RT   t   lower(   RJ   (    (    s8   /tmp/pip-build-sZz8gW/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   verboset   loggert   infoRT   RY   t   locationt   format_for_json(   R(   RE   R4   t   datat   headerRJ   (    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRD   Ñ   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(    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRi   ì   s    (   t   lent   insertt   tabulatet   joint   mapRn   Ro   (   R(   Rr   Rs   t   pkg_stringst   sizest   val(    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRl   ã   s    ((   t   __name__t
   __module__t   __doc__t   namet   usaget   summaryR   R5   RF   RB   RC   RA   RG   RD   Rl   (    (    (    s8   /tmp/pip-build-sZz8gW/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(   Rw   (   RL   Rv   (    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pys	   <genexpr>÷   s    Rt   t    (	   Rw   t   AssertionErrort   maxR   t   strRz   R]   t   ljustt   append(   t   valsR}   t   rowt   st   ct   resultt   display(    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRy   ò   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	   (   RL   Rv   (    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pys	   <genexpr>  s    t   Locationt	   Installer(   R;   Rm   t   anyRŠ   RT   RY   RH   R`   R	   Rp   R   (   t   pkgsR4   t   running_outdatedRs   Rr   t   projRŒ   (    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRk     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(   NR‚   RY   i   Rp   t	   installerRH   R`   (   RT   R   t	   text_typeRY   Rm   Rp   R   R;   RH   R`   RŠ   R   t   dumps(   RE   R4   Rr   RJ   Ro   (    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyRq   )  s    
	(    t
   __future__R    R   t   loggingt   pip._vendorR   t   pip._vendor.six.movesR   t   pip._internal.cliR   t   pip._internal.cli.base_commandR   t   pip._internal.cli.cmdoptionsR   t   pip._internal.exceptionsR   t   pip._internal.indexR   t$   pip._internal.models.selection_prefsR   t   pip._internal.utils.miscR	   R
   t   pip._internal.utils.packagingR   t	   getLoggerR   Rn   R   Ry   Rk   Rq   (    (    (    s8   /tmp/pip-build-sZz8gW/pip/pip/_internal/commands/list.pyt   <module>   s"   Û		%