ó
©9Vc           @@  sã   d  d l  m 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
 m Z m Z 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 S(   i    (   t   absolute_importN(   t   pkg_resources(   t   Command(   t   DistributionNotFound(   t   FormatControlt   fmt_ctl_formatst   PackageFindert   Search(   t   InstallRequirement(   t   get_installed_distributionst   dist_is_editable(   t
   WheelCache(   t   make_option_groupt   index_groupt   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 d d d d t d d ƒt t |  j ƒ } |  j j	 d | ƒ |  j j	 d | ƒ d  S(   Ns   -os
   --outdatedt   actiont
   store_truet   defaultt   helps,   List outdated packages (excluding editables)s   -us
   --uptodates,   List uptodate packages (excluding editables)s   -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.i    (
   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-5Z5nTX/pip/pip/commands/list.pyR      sH    						c         C@  sR   t  d | j d | d | j d | j d | j d | j d | j d | j d	 | ƒ 	S(
   sK   
        Create a package finder appropriate to this list command.
        t
   find_linkst
   index_urlst   allow_externalt   allow_unverifiedt   allow_all_externalt   allow_all_prereleasest   trusted_hostst   process_dependency_linkst   session(   R   R!   R#   R$   R%   t   preR'   R(   (   R   t   optionsR"   R)   (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyt   _build_package_finderM   s    							c         C@  s\   | j  r |  j | ƒ n? | j r2 |  j | ƒ n& | j rK |  j | ƒ n |  j | ƒ d  S(   N(   t   outdatedt   run_outdatedt   uptodatet   run_uptodatet   editablet   run_editablest   run_listing(   R   R+   R   (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyt   run]   s    			c         C@  sX   xQ |  j  | ƒ D]@ \ } } } | | j k r t j d | j | j | | ƒ q q Wd  S(   Ns    %s (Current: %s Latest: %s [%s])(   t   find_packages_latest_versionst   parsed_versiont   loggert   infot   project_namet   version(   R   R+   t   distR:   t   typ(    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyR.   g   s
    c         c@  s	  | j  g | j } | j r> t j d d j | ƒ ƒ g  } n  g  } xK t d | j d | j ƒ D]. } | j	 d ƒ r` | j
 | j d ƒ ƒ q` q` W|  j | ƒ b} |  j | | | ƒ } | j | ƒ t d | j d | j d t ƒ } t t ƒ  t ƒ  ƒ } t | j | ƒ }	 xî | D]æ } t j | j d  d | j d |	 ƒ}
 d	 } y( | j |
 t ƒ } | d  k rlwn  Wn t k
 rƒqnj Xt j |
 j ƒ j ƒ  } t  | | ƒ } t! |
 j | | ƒ } | j" | | ƒ j# } | j$ rçd
 } n d } | | | f VqWWd  QXd  S(   Ns   Ignoring indexes: %st   ,t
   local_onlyt	   user_onlys   dependency_links.txtt   include_editablest   isolatedt   wheel_cachet   unknownt   wheelt   sdist(%   t	   index_urlt   extra_index_urlst   no_indexR7   R8   t   joinR	   t   localR   t   has_metadatat   extendt   get_metadata_linest   _build_sessionR,   t   add_dependency_linksR   R   t   setR   t	   cache_dirR   t	   from_linet   keyt   Nonet   isolated_modet   find_requirementt   TrueR   R   t	   safe_namet   namet   lowerR   R   t   _link_package_versionsR:   t   is_wheel(   R   R+   R"   t   dependency_linksR;   R)   t   findert   installed_packagest   format_controlRB   t   reqR<   t   linkt   canonical_namet   formatst   searcht   remote_version(    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyR5   o   sT    						
			c         C@  s,   t  d | j d | j ƒ } |  j | ƒ d  S(   NR>   R?   (   R	   RJ   R   t   output_package_listing(   R   R+   R_   (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyR3   ¦   s    	c         C@  s2   t  d | j d | j d t ƒ } |  j | ƒ d  S(   NR>   R?   t   editables_only(   R	   RJ   R   RW   Rg   (   R   R+   R_   (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyR2   ­   s
    			c         C@  sx   t  | d d „  ƒ} x\ | D]T } t | ƒ rM d | j | j | j f } n d | j | j f } t j | ƒ q Wd  S(   NRS   c         S@  s   |  j  j ƒ  S(   N(   R9   RZ   (   R;   (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyt   <lambda>¸   s    s   %s (%s, %s)s   %s (%s)(   t   sortedR
   R9   R:   t   locationR7   R8   (   R   R_   R;   t   line(    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyRg   µ   s    c         C@  sY   g  } x? |  j  | ƒ D]. \ } } } | j | k r | j | ƒ q q W|  j | ƒ d  S(   N(   R5   R6   t   appendRg   (   R   R+   R/   R;   R:   R<   (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyR0   Å   s
    (   t   __name__t
   __module__t   __doc__RY   t   usaget   summaryR   R,   R4   R.   R5   R3   R2   Rg   R0   (    (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyR      s   	/		
		7			(   t
   __future__R    t   loggingt   pip._vendorR   t   pip.basecommandR   t   pip.exceptionsR   t	   pip.indexR   R   R   R   t   pip.reqR   t	   pip.utilsR	   R
   t	   pip.wheelR   t   pip.cmdoptionsR   R   t	   getLoggerRn   R7   R   (    (    (    s.   /tmp/pip-build-5Z5nTX/pip/pip/commands/list.pyt   <module>   s   "