5from typing
import Callable, Iterable, Optional, Tuple
14FoundCandidates = Iterable[InstallationCandidate]
15FoundLinks = Iterable[Link]
16CandidatesFromPage = Callable[[Link], Iterable[InstallationCandidate]]
17PageValidator = Callable[[Link], bool]
22 def link(self) -> Optional[Link]:
23 """Returns the underlying link, if there's one."""
27 """Candidates found by parsing an archive listing HTML file."""
31 """Links found by specifying archives directly."""
40 """Link source specified by ``--find-links=<path-to-dir>``.
42 This looks the content of the directory, and returns:
44 * ``page_candidates``: Links listed on each HTML file in the directory.
45 * ``file_candidates``: Archives in the directory.
50 candidates_from_page: CandidatesFromPage,
57 def link(self) -> Optional[Link]:
61 for path
in self.
_path.iterdir():
62 url = path_to_url(str(path))
68 for path
in self.
_path.iterdir():
69 url = path_to_url(str(path))
76 """``--find-links=<path-or-url>`` or ``--[extra-]index-url=<path-or-url>``.
78 If a URL is supplied, it must be a ``file:`` URL. If a path is supplied to
79 the option, it is converted to a URL first. This returns:
81 * ``page_candidates``: Links listed on an HTML file.
82 * ``file_candidates``: The non-HTML file.
87 candidates_from_page: CandidatesFromPage,
94 def link(self) -> Optional[Link]:
109 """``--find-links=<url>`` or ``--[extra-]index-url=<url>``.
113 * ``page_candidates``: Links listed on an HTML file.
114 * ``file_candidates``: The non-HTML file.
119 candidates_from_page: CandidatesFromPage,
120 page_validator: PageValidator,
128 def link(self) -> Optional[Link]:
141 """``--[extra-]index-url=<path-to-directory>``.
143 This is treated like a remote URL; ``candidates_from_page`` contains logic
144 for this by appending ``index.html`` to the link.
149 candidates_from_page: CandidatesFromPage,
156 def link(self) -> Optional[Link]:
169 candidates_from_page: CandidatesFromPage,
170 page_validator: PageValidator,
172 cache_link_parsing: bool,
173) -> Tuple[Optional[str], Optional[LinkSource]]:
174 path: Optional[str] =
None
175 url: Optional[str] =
None
177 url = path_to_url(location)
181 path = url_to_path(location)
182 elif is_url(location):
187 "Location '%s' is ignored: "
188 "it is either a non-existing path or lacks a specific scheme."
195 candidates_from_page=candidates_from_page,
196 page_validator=page_validator,
197 link=
Link(url, cache_link_parsing=cache_link_parsing),
204 candidates_from_page=candidates_from_page,
209 candidates_from_page=candidates_from_page,
210 link=
Link(url, cache_link_parsing=cache_link_parsing),
215 candidates_from_page=candidates_from_page,
216 link=
Link(url, cache_link_parsing=cache_link_parsing),
220 "Location '%s' is ignored: it is neither a file nor a directory.",
FoundCandidates page_candidates(self)
Optional[Link] link(self)
FoundLinks file_links(self)
FoundCandidates page_candidates(self)
Optional[Link] link(self)
FoundLinks file_links(self)
None __init__(self, CandidatesFromPage candidates_from_page, str path)
None __init__(self, CandidatesFromPage candidates_from_page, Link link)
FoundCandidates page_candidates(self)
Optional[Link] link(self)
FoundLinks file_links(self)
None __init__(self, CandidatesFromPage candidates_from_page, Link link)
FoundCandidates page_candidates(self)
Optional[Link] link(self)
FoundLinks file_links(self)
None __init__(self, CandidatesFromPage candidates_from_page, PageValidator page_validator, Link link)
FoundCandidates page_candidates(self)
Optional[Link] link(self)
FoundLinks file_links(self)
bool _is_html_file(str file_url)