Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
SearchCommand Class Reference
Inheritance diagram for SearchCommand:
Collaboration diagram for SearchCommand:

Public Member Functions

None add_options (self)
 
int run (self, Values options, List[str] args)
 
List[Dict[str, str]] search (self, List[str] query, Values options)
 
- Public Member Functions inherited from Command
None __init__ (self, str name, str summary, bool isolated=False)
 
None handle_pip_version_check (self, Values options)
 
Tuple[Values, List[str]] parse_args (self, List[str] args)
 
int main (self, List[str] args)
 
- Public Member Functions inherited from CommandContextMixIn
Generator[None, None, Nonemain_context (self)
 
_T enter_context (self, ContextManager[_T] context_provider)
 
- Public Member Functions inherited from SessionCommandMixin
None __init__ (self)
 
PipSession get_default_session (self, Values options)
 

Data Fields

 cmd_opts
 
- Data Fields inherited from Command
 name
 
 summary
 
 parser
 
 cmd_opts
 
 tempdir_registry
 
 verbosity
 

Static Public Attributes

str usage
 
bool ignore_require_venv = True
 
- Static Public Attributes inherited from Command
str usage = ""
 
bool ignore_require_venv = False
 

Additional Inherited Members

- Protected Member Functions inherited from Command
int _main (self, List[str] args)
 
- Protected Member Functions inherited from SessionCommandMixin
Optional[List[str]] _get_index_urls (cls, Values options)
 
PipSession _build_session (self, Values options, Optional[int] retries=None, Optional[int] timeout=None, bool fallback_to_certifi=False)
 
- Protected Attributes inherited from CommandContextMixIn
 _in_main_context
 
 _main_context
 
- Protected Attributes inherited from SessionCommandMixin
 _session
 

Detailed Description

Search for PyPI packages whose name or summary contains <query>.

Definition at line 34 of file search.py.

Member Function Documentation

◆ add_options()

None add_options (   self)

Reimplemented from Command.

Definition at line 41 of file search.py.

41 def add_options(self) -> None:
42 self.cmd_opts.add_option(
43 "-i",
44 "--index",
45 dest="index",
46 metavar="URL",
47 default=PyPI.pypi_url,
48 help="Base URL of Python Package Index (default %default)",
49 )
50
51 self.parser.insert_option_group(0, self.cmd_opts)
52
for i

References Command.cmd_opts, CacheCommand.cmd_opts, CompletionCommand.cmd_opts, ConfigurationCommand.cmd_opts, DebugCommand.cmd_opts, DownloadCommand.cmd_opts, FreezeCommand.cmd_opts, HashCommand.cmd_opts, IndexCommand.cmd_opts, InspectCommand.cmd_opts, InstallCommand.cmd_opts, ListCommand.cmd_opts, SearchCommand.cmd_opts, ShowCommand.cmd_opts, UninstallCommand.cmd_opts, WheelCommand.cmd_opts, and i.

◆ run()

int run (   self,
Values  options,
List[str]  args 
)

Reimplemented from Command.

Definition at line 53 of file search.py.

53 def run(self, options: Values, args: List[str]) -> int:
54 if not args:
55 raise CommandError("Missing required argument (search query).")
56 query = args
57 pypi_hits = self.search(query, options)
58 hits = transform_hits(pypi_hits)
59
60 terminal_width = None
62 terminal_width = shutil.get_terminal_size()[0]
63
64 print_results(hits, terminal_width=terminal_width)
65 if pypi_hits:
66 return SUCCESS
67 return NO_MATCHES_FOUND
68

References i, pip._internal.commands.search.print_results(), SearchCommand.search(), PackageIndex.search(), and pip._internal.commands.search.transform_hits().

Here is the call graph for this function:

◆ search()

List[Dict[str, str]] search (   self,
List[str]  query,
Values  options 
)

Definition at line 69 of file search.py.

69 def search(self, query: List[str], options: Values) -> List[Dict[str, str]]:
70 index_url = options.index
71
72 session = self.get_default_session(options)
73
74 transport = PipXmlrpcTransport(index_url, session)
75 pypi = xmlrpc.client.ServerProxy(index_url, transport)
76 try:
77 hits = pypi.search({"name": query, "summary": query}, "or")
78 except xmlrpc.client.Fault as fault:
79 message = "XMLRPC request failed [code: {code}]\n{string}".format(
80 code=fault.faultCode,
81 string=fault.faultString,
82 )
83 raise CommandError(message)
84 assert isinstance(hits, list)
85 return hits
86
87

References SessionCommandMixin.get_default_session(), and i.

Referenced by SearchCommand.run().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ cmd_opts

◆ ignore_require_venv

bool ignore_require_venv = True
static

Definition at line 39 of file search.py.

◆ usage

str usage
static
Initial value:
= """
%prog [options] <query>"""

Definition at line 37 of file search.py.


The documentation for this class was generated from the following file: