AlkantarClanX12

Your IP : 3.147.68.39


Current Path : /opt/alt/python34/lib/python3.4/site-packages/pip/commands/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib/python3.4/site-packages/pip/commands/__pycache__/search.cpython-34.pyc

�
�Re��@sddlZddlZddlZddlmZmZddlmZddl	m
Z
ddlmZm
Z
mZddlmZddlmZddlmZdd	lmZmZGd
d�de�Zdd
�Zdddd�Zdd�Zdd�ZdS)�N)�Command�SUCCESS)�get_terminal_size)�logger)�	xmlrpclib�reduce�cmp)�CommandError)�NO_MATCHES_FOUND)�
pkg_resources)�
StrictVersion�LooseVersioncsReZdZdZdZdZdZ�fdd�Zdd�Zd	d
�Z	�S)�
SearchCommandz@Search for PyPI packages whose name or summary contains <query>.�searchz
      %prog [options] <query>zSearch PyPI for packages.c
s[tt|�j||�|jjddddddddd	�|jjd
|j�dS)Nz--index�dest�index�metavar�URL�defaultzhttps://pypi.python.org/pypi�helpz3Base URL of Python Package Index (default %default)r)�superr�__init__�cmd_opts�
add_option�parser�insert_option_group)�self�args�kw)�	__class__��./tmp/pip-ztkk0jow-build/pip/commands/search.pyrs	zSearchCommand.__init__cCs�|std��n|}|j}|j||�}t|�}d}tjj�rgt�d}nt|d|�|r�t	St
S)Nz)Missing required argument (search query).r�terminal_width)r	rr�transform_hits�sys�stdout�isattyr�
print_resultsrr
)r�optionsr�query�	index_url�	pypi_hits�hitsr"r r r!�run"s	zSearchCommand.runcCs3tj|�}|ji|d6|d6d�}|S)N�name�summary�or)r�ServerProxyr)rr)r*�pypir,r r r!r4s zSearchCommand.search)
�__name__�
__module__�__qualname__�__doc__r.�usager/rr-rr r )rr!rsrcCsi}x�|D]�}|d}|d}|d}|d}|dkrPd}n||j�kr�i|d6|d6|gd6|d6||<q
||dj|�|t||d�kr
|||d<|||d<q
q
Wt|j�d	d
d�dd
�}|S)z�
    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/�version�_pypi_orderingNr�versions�score�keycSs|dS)Nr;r )�xr r r!�<lambda>Tsz transform_hits.<locals>.<lambda>�reverseT)�keys�append�highest_version�sorted�values)r,�packages�hitr.r/r8r;�package_listr r r!r#:s 




	,$r#�c
Csgdd�tjD�}xJ|D]B}|d}|dp:d}|dk	r�tj|||d�}dd|d	j|�}nd
|j|�|f}y�tj|�||krItj|�}tj	d7_	z_t
|d�}	|j|	kr
tjd
|j�n%tjd|j�tjd|	�Wdtj	d8_	XnWqtk
r^YqXqWdS)NcSsg|]}|j�qSr )�project_name)�.0�pr r r!�
<listcomp>Ys	z!print_results.<locals>.<listcomp>r.r/���
� �z%s - %s�r:zINSTALLED: %s (latest)z
INSTALLED: %sz
LATEST:    %s)
r�working_set�textwrap�wrap�join�ljustr�notify�get_distribution�indentrBr8�UnicodeEncodeError)
r,�name_column_widthr"�installed_packagesrFr.r/�line�dist�latestr r r!r'Xs,



r'cCs�ytt|�t|��SWntk
r1YnXytt|�t|��SWnKtk
r�tdd�t|�jD�dd�t|�jD��SYnXdS)NcSsg|]}t|��qSr )�str)rJ�vr r r!rLs	z$compare_versions.<locals>.<listcomp>cSsg|]}t|��qSr )ra)rJrbr r r!rL�s	)rr�
ValueErrorr
�	TypeErrorr8)�version1�version2r r r!�compare_versionsts

rgcCstdd�|�S)NcSst||�dkr|p|S)N�)rg)�v1�v2r r r!r>�sz!highest_version.<locals>.<lambda>)r)r:r r r!rB�srB)r$rT�pip.download�pip�pip.basecommandrr�pip.utilr�pip.logrZpip.backwardcompatrrr�pip.exceptionsr	�pip.status_codesr
�pip._vendorr�distutils.versionrr
rr#r'rgrBr r r r!�<module>s*