Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._internal.commands.search Namespace Reference

Data Structures

class  SearchCommand
 
class  TransformedHit
 

Functions

List["TransformedHit"] transform_hits (List[Dict[str, str]] hits)
 
None print_dist_installation_info (str name, str latest)
 
None print_results (List["TransformedHit"] hits, Optional[int] name_column_width=None, Optional[int] terminal_width=None)
 
str highest_version (List[str] versions)
 

Variables

 logger = logging.getLogger(__name__)
 

Function Documentation

◆ highest_version()

str highest_version ( List[str]  versions)

Definition at line 173 of file search.py.

173def highest_version(versions: List[str]) -> str:
174 return max(versions, key=parse_version)

Referenced by pip._internal.commands.search.print_results(), and pip._internal.commands.search.transform_hits().

Here is the caller graph for this function:

◆ print_dist_installation_info()

None print_dist_installation_info ( str  name,
str  latest 
)

Definition at line 116 of file search.py.

116def print_dist_installation_info(name: str, latest: str) -> None:
117 env = get_default_environment()
118 dist = env.get_distribution(name)
119 if dist is not None:
120 with indent_log():
121 if dist.version == latest:
122 write_output("INSTALLED: %s (latest)", dist.version)
123 else:
124 write_output("INSTALLED: %s", dist.version)
125 if parse_version(latest).pre:
126 write_output(
127 "LATEST: %s (pre-release; install"
128 " with `pip install --pre`)",
129 latest,
130 )
131 else:
132 write_output("LATEST: %s", latest)
133
134
for i

References i.

◆ print_results()

None print_results ( List["TransformedHit"]  hits,
Optional[int]   name_column_width = None,
Optional[int]   terminal_width = None 
)

Definition at line 135 of file search.py.

139) -> None:
140 if not hits:
141 return
142 if name_column_width is None:
143 name_column_width = (
144 max(
145 [
146 len(hit["name"]) + len(highest_version(hit.get("versions", ["-"])))
147 for hit in hits
148 ]
149 )
150 + 4
151 )
152
153 for hit in hits:
154 name = hit["name"]
155 summary = hit["summary"] or ""
156 latest = highest_version(hit.get("versions", ["-"]))
157 if terminal_width is not None:
158 target_width = terminal_width - name_column_width - 5
159 if target_width > 10:
160 # wrap and indent summary to fit terminal
161 summary_lines = textwrap.wrap(summary, target_width)
162 summary = ("\n" + " " * (name_column_width + 3)).join(summary_lines)
163
164 name_latest = f"{name} ({latest})"
165 line = f"{name_latest:{name_column_width}} - {summary}"
166 try:
167 write_output(line)
168 print_dist_installation_info(name, latest)
169 except UnicodeEncodeError:
170 pass
171
172

References pip._internal.commands.search.highest_version(), and i.

Referenced by SearchCommand.run().

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

◆ transform_hits()

List["TransformedHit"] transform_hits ( List[Dict[str, str]]  hits)
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.

Definition at line 88 of file search.py.

88def transform_hits(hits: List[Dict[str, str]]) -> List["TransformedHit"]:
89 """
90 The list from pypi is really a list of versions. We want a list of
91 packages with the list of versions stored inline. This converts the
92 list from pypi into one we can use.
93 """
94 packages: Dict[str, "TransformedHit"] = OrderedDict()
95 for hit in hits:
96 name = hit["name"]
97 summary = hit["summary"]
98 version = hit["version"]
99
100 if name not in packages.keys():
101 packages[name] = {
102 "name": name,
103 "summary": summary,
104 "versions": [version],
105 }
106 else:
107 packages[name]["versions"].append(version)
108
109 # if this is the highest version, replace summary and score
110 if version == highest_version(packages[name]["versions"]):
111 packages[name]["summary"] = summary
112
113 return list(packages.values())
114
115

References pip._internal.commands.search.highest_version(), and i.

Referenced by SearchCommand.run().

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

Variable Documentation

◆ logger

logger = logging.getLogger(__name__)

Definition at line 31 of file search.py.