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

Public Member Functions

None add_options (self)
 
int run (self, Values options, List[str] args)
 
None get_available_package_versions (self, Values options, List[Any] args)
 
- Public Member Functions inherited from IndexGroupCommand
None handle_pip_version_check (self, Values options)
 
- Public Member Functions inherited from Command
None __init__ (self, str name, str summary, bool isolated=False)
 
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
 
 parser
 
 get_available_package_versions
 
- Data Fields inherited from Command
 name
 
 summary
 
 parser
 
 cmd_opts
 
 tempdir_registry
 
 verbosity
 

Static Public Attributes

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

Protected Member Functions

PackageFinder _build_package_finder (self, Values options, PipSession session, Optional[TargetPython] target_python=None, Optional[bool] ignore_requires_python=None)
 
- 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)
 

Additional Inherited Members

- Protected Attributes inherited from CommandContextMixIn
 _in_main_context
 
 _main_context
 
- Protected Attributes inherited from SessionCommandMixin
 _session
 

Detailed Description

Inspect information available from package indexes.

Definition at line 22 of file index.py.

Member Function Documentation

◆ _build_package_finder()

PackageFinder _build_package_finder (   self,
Values  options,
PipSession  session,
Optional[TargetPython]   target_python = None,
Optional[bool]   ignore_requires_python = None 
)
protected
Create a package finder appropriate to the index command.

Definition at line 78 of file index.py.

84 ) -> PackageFinder:
85 """
86 Create a package finder appropriate to the index command.
87 """
88 link_collector = LinkCollector.create(session, options=options)
89
90 # Pass allow_yanked=False to ignore yanked versions.
91 selection_prefs = SelectionPreferences(
92 allow_yanked=False,
93 allow_all_prereleases=options.pre,
94 ignore_requires_python=ignore_requires_python,
95 )
96
98 link_collector=link_collector,
99 selection_prefs=selection_prefs,
100 target_python=target_python,
101 )
102
for i

References i.

Referenced by IndexCommand.get_available_package_versions(), ListCommand.iter_packages_latest_infos(), DownloadCommand.run(), InstallCommand.run(), and WheelCommand.run().

Here is the caller graph for this function:

◆ add_options()

None add_options (   self)

Reimplemented from Command.

Definition at line 32 of file index.py.

32 def add_options(self) -> None:
34
36 self.cmd_opts.add_option(cmdoptions.pre())
37 self.cmd_opts.add_option(cmdoptions.no_binary())
38 self.cmd_opts.add_option(cmdoptions.only_binary())
39
42 self.parser,
43 )
44
45 self.parser.insert_option_group(0, index_opts)
46 self.parser.insert_option_group(0, self.cmd_opts)
47

◆ get_available_package_versions()

None get_available_package_versions (   self,
Values  options,
List[Any]  args 
)

Definition at line 103 of file index.py.

103 def get_available_package_versions(self, options: Values, args: List[Any]) -> None:
104 if len(args) != 1:
105 raise CommandError("You need to specify exactly one argument")
106
107 target_python = cmdoptions.make_target_python(options)
108 query = args[0]
109
110 with self._build_session(options) as session:
111 finder = self._build_package_finder(
112 options=options,
113 session=session,
114 target_python=target_python,
115 ignore_requires_python=options.ignore_requires_python,
116 )
117
118 versions: Iterable[Union[LegacyVersion, Version]] = (
119 candidate.version for candidate in finder.find_all_candidates(query)
120 )
121
122 if not options.pre:
123 # Remove prereleases
124 versions = (
125 version for version in versions if not version.is_prerelease
126 )
127 versions = set(versions)
128
129 if not versions:
130 raise DistributionNotFound(
131 "No matching distribution found for {}".format(query)
132 )
133
134 formatted_versions = [str(ver) for ver in sorted(versions, reverse=True)]
135 latest = formatted_versions[0]
136
137 write_output("{} ({})".format(query, latest))
138 write_output("Available versions: {}".format(", ".join(formatted_versions)))
139 print_dist_installation_info(query, latest)

References ListCommand._build_package_finder(), RequirementCommand._build_package_finder(), IndexCommand._build_package_finder(), SessionCommandMixin._build_session(), and i.

Here is the call graph for this function:

◆ run()

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

Reimplemented from Command.

Definition at line 48 of file index.py.

48 def run(self, options: Values, args: List[str]) -> int:
49 handlers = {
50 "versions": self.get_available_package_versions,
51 }
52
54 "pip index is currently an experimental command. "
55 "It may be removed/changed in a future release "
56 "without prior warning."
57 )
58
59 # Determine action
60 if not args or args[0] not in handlers:
62 "Need an action (%s) to perform.",
63 ", ".join(sorted(handlers)),
64 )
65 return ERROR
66
67 action = args[0]
68
69 # Error handling happens here, not in the action-handlers.
70 try:
71 handlers[action](options, args[1:])
72 except PipError as e:
74 return ERROR
75
76 return SUCCESS
77

Field Documentation

◆ cmd_opts

◆ get_available_package_versions

get_available_package_versions

Definition at line 50 of file index.py.

◆ ignore_require_venv

bool ignore_require_venv = True
static

Definition at line 27 of file index.py.

◆ parser

◆ usage

str usage
static
Initial value:
= """
%prog versions <package>
"""

Definition at line 28 of file index.py.


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