ó
û_¾Tc           @   s  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m Z 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 d  d l m Z d  d l m Z m Z d	 e f d
 „  ƒ  YZ d „  Z d d d „ Z d „  Z d „  Z e ƒ  d S(   iÿÿÿÿN(   t   Commandt   SUCCESS(   t   get_terminal_size(   t   logger(   t	   xmlrpclibt   reducet   cmp(   t   CommandError(   t   NO_MATCHES_FOUND(   t   StrictVersiont   LooseVersiont   SearchCommandc           B   s5   e  Z d  Z d Z d Z d „  Z d „  Z d „  Z RS(   t   searchs   %prog QUERYs   Search PyPIc      
   C   s?   t  t |  ƒ j ƒ  |  j j d d d d d d d d d	 ƒd  S(
   Ns   --indext   destt   indext   metavart   URLt   defaults   http://pypi.python.org/pypit   helps3   Base URL of Python Package Index (default %default)(   t   superR   t   __init__t   parsert
   add_option(   t   self(    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyR      s    	c         C   s…   | s t  d ƒ ‚ n  | } | j } |  j | | ƒ } t | ƒ } d  } t j j ƒ  rg t ƒ  d } n  t	 | d | ƒ| r t
 St S(   Ns)   Missing required argument (search query).i    t   terminal_width(   R   R   R   t   transform_hitst   Nonet   syst   stdoutt   isattyR   t   print_resultsR   R   (   R   t   optionst   argst   queryt	   index_urlt	   pypi_hitst   hitsR   (    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyt   run   s    	c         C   s<   t  j | t j j ƒ } | j i | d 6| d 6d ƒ } | S(   Nt   namet   summaryt   or(   R   t   ServerProxyt   pipt   downloadt   xmlrpclib_transportR   (   R   R!   R"   t   pypiR$   (    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyR   .   s     (   t   __name__t
   __module__R&   t   usageR'   R   R%   R   (    (    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyR      s   			c         C   sð   i  } xÂ |  D]º } | d } | d } | d } | d } | | j  ƒ  k ry i | d 6| d 6| g d 6| d 6| | <q | | d j | ƒ | t | | d ƒ k r | | | d <| | | d <q q Wt | j ƒ  d d „  d	 t ƒ} | S(
   s¼   
    The list from pypi is really a list of versions. We want a list of
    packages with the list of versions stored inline. This converts the
    list from pypi into one we can use.
    R&   R'   t   versiont   _pypi_orderingt   versionst   scoret   keyc         S   s   |  d S(   NR4   (    (   t   x(    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyt   <lambda>L   s    t   reverse(   t   keyst   appendt   highest_versiont   sortedt   valuest   True(   R$   t   packagest   hitR&   R'   R1   R4   t   package_list(    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyR   4   s    



,!i   c         C   so  g  t  j D] } | j ^ q
 } xI|  D]A} | d } | d pC d } | d  k	 rŠ t j | | | d ƒ } d d | d j | ƒ } n  d | j | ƒ | f } y° t j	 | ƒ | | k rRt  j
 | ƒ }	 t j d	 7_ z_ t | d
 ƒ }
 |	 j |
 k rt j	 d |	 j ƒ n% t j	 d |	 j ƒ t j	 d |
 ƒ Wd  t j d	 8_ Xn  Wq& t k
 rfq& Xq& Wd  S(   NR&   R'   t    i   s   
t    i   s   %s - %si   R3   s   INSTALLED: %s (latest)s   INSTALLED: %ss   LATEST:    %s(   t   pkg_resourcest   working_sett   project_nameR   t   textwrapt   wrapt   joint   ljustR   t   notifyt   get_distributiont   indentR;   R1   t   UnicodeEncodeError(   R$   t   name_column_widthR   t   pt   installed_packagesR@   R&   R'   t   linet   distt   latest(    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyR   P   s,    
c         C   s´   y t  t |  ƒ t | ƒ ƒ SWn t k
 r0 n Xy t  t |  ƒ t | ƒ ƒ SWn_ t k
 r¯ t  g  t |  ƒ j D] } t | ƒ ^ qq g  t | ƒ j D] } t | ƒ ^ q– ƒ SXd  S(   N(   R   R	   t
   ValueErrorR
   t	   TypeErrorR1   t   str(   t   version1t   version2t   v(    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyt   compare_versionsl   s    (c         C   s   t  d „  |  ƒ S(   Nc         S   s   t  |  | ƒ d k r |  p | S(   Ni   (   R[   (   t   v1t   v2(    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyR7   |   s    (   R   (   R3   (    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyR;   {   s    (   R   RG   RD   t   pip.downloadR*   t   pip.basecommandR    R   t   pip.utilR   t   pip.logR   t   pip.backwardcompatR   R   R   t   pip.exceptionsR   t   pip.status_codesR   t   distutils.versionR	   R
   R   R   R   R   R[   R;   (    (    (    sk   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/search.pyt   <module>   s    &			