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

Data Structures

class  _FlatDirectorySource
 
class  _IndexDirectorySource
 
class  _LocalFileSource
 
class  _RemoteFileSource
 
class  LinkSource
 

Functions

bool _is_html_file (str file_url)
 
Tuple[Optional[str], Optional[LinkSource]] build_source (str location, *CandidatesFromPage candidates_from_page, PageValidator page_validator, bool expand_dir, bool cache_link_parsing)
 

Variables

 logger = logging.getLogger(__name__)
 
 FoundCandidates = Iterable[InstallationCandidate]
 
 FoundLinks = Iterable[Link]
 
 CandidatesFromPage = Callable[[Link], Iterable[InstallationCandidate]]
 
 PageValidator = Callable[[Link], bool]
 

Function Documentation

◆ _is_html_file()

bool _is_html_file ( str  file_url)
protected

Definition at line 35 of file sources.py.

35def _is_html_file(file_url: str) -> bool:
36 return mimetypes.guess_type(file_url, strict=False)[0] == "text/html"
37
38
for i

References i.

Referenced by _FlatDirectorySource.file_links(), _LocalFileSource.file_links(), _FlatDirectorySource.page_candidates(), and _LocalFileSource.page_candidates().

Here is the caller graph for this function:

◆ build_source()

Tuple[Optional[str], Optional[LinkSource]] build_source ( str  location,
*CandidatesFromPage  candidates_from_page,
PageValidator  page_validator,
bool  expand_dir,
bool  cache_link_parsing 
)

Definition at line 166 of file sources.py.

173) -> Tuple[Optional[str], Optional[LinkSource]]:
174 path: Optional[str] = None
175 url: Optional[str] = None
176 if os.path.exists(location): # Is a local path.
177 url = path_to_url(location)
178 path = location
179 elif location.startswith("file:"): # A file: URL.
180 url = location
181 path = url_to_path(location)
182 elif is_url(location):
183 url = location
184
185 if url is None:
186 msg = (
187 "Location '%s' is ignored: "
188 "it is either a non-existing path or lacks a specific scheme."
189 )
190 logger.warning(msg, location)
191 return (None, None)
192
193 if path is None:
194 source: LinkSource = _RemoteFileSource(
195 candidates_from_page=candidates_from_page,
196 page_validator=page_validator,
197 link=Link(url, cache_link_parsing=cache_link_parsing),
198 )
199 return (url, source)
200
201 if os.path.isdir(path):
202 if expand_dir:
203 source = _FlatDirectorySource(
204 candidates_from_page=candidates_from_page,
205 path=path,
206 )
207 else:
208 source = _IndexDirectorySource(
209 candidates_from_page=candidates_from_page,
210 link=Link(url, cache_link_parsing=cache_link_parsing),
211 )
212 return (url, source)
213 elif os.path.isfile(path):
214 source = _LocalFileSource(
215 candidates_from_page=candidates_from_page,
216 link=Link(url, cache_link_parsing=cache_link_parsing),
217 )
218 return (url, source)
220 "Location '%s' is ignored: it is neither a file nor a directory.",
221 location,
222 )
223 return (url, None)

References i.

Variable Documentation

◆ CandidatesFromPage

CandidatesFromPage = Callable[[Link], Iterable[InstallationCandidate]]

Definition at line 16 of file sources.py.

◆ FoundCandidates

FoundCandidates = Iterable[InstallationCandidate]

Definition at line 14 of file sources.py.

◆ FoundLinks

FoundLinks = Iterable[Link]

Definition at line 15 of file sources.py.

◆ logger

logger = logging.getLogger(__name__)

Definition at line 12 of file sources.py.

◆ PageValidator

PageValidator = Callable[[Link], bool]

Definition at line 17 of file sources.py.