3 Pf@sddlmZddlZddlZddlZddlmZmZddlm Z ddl m Z ddl m Z ddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZejeZGdddeZ ddZ!dddZ"ddZ#dS))absolute_importN)CommandSUCCESS) OrderedDict)PipXmlrpcTransport)PyPI)get_terminal_size) indent_log) CommandError)NO_MATCHES_FOUND)parse) pkg_resources) xmlrpc_clientcs<eZdZdZdZdZdZfddZddZd d Z Z S) SearchCommandz@Search for PyPI packages whose name or summary contains .searchz %prog [options] zSearch PyPI for packages.cs@tt|j|||jjddddtjdd|jjd|jdS)Nz-iz--indexindexZURLz3Base URL of Python Package Index (default %default))destmetavardefaulthelpr) superr__init__Zcmd_optsZ add_optionrZpypi_urlparserZinsert_option_group)selfargskw) __class__/usr/lib/python3.6/search.pyrszSearchCommand.__init__cCsT|s td|}|j||}t|}d}tjjrt k rJYq>Xq>WdS)NcSs.g|]&}t|dt|jddgdqS)r)r2-)lenget).0r8rrr csz!print_results..cSsg|] }|jqSr)Z project_name)r>prrrr?gsr)r*r2r9r:   z %-*s - %sz%s (%s)zINSTALLED: %s (latest)z INSTALLED: %sz LATEST: %sr;)maxr Z working_setr=textwrapZwrapjoinloggerinfoZget_distributionr r5r1UnicodeEncodeError) r'Zname_column_widthrZinstalled_packagesr8r)r*r1Z target_widthlineZdistZlatestrrrr$^s>        r$cCs t|tdS)N)key)rH parse_version)r2rrrr5sr5)NN)$Z __future__rZloggingr!rIZpip.basecommandrrZ pip.compatrZ pip.downloadrZ pip.modelsrZ pip.utilsrZpip.utils.loggingr Zpip.exceptionsr Zpip.status_codesr Zpip._vendor.packaging.versionr rPZ pip._vendorr Zpip._vendor.six.movesrZ getLoggerr,rKrr r$r5rrrrs&            + &