o ƚRe@s<ddlZddlZddlZddlZddlmZmZmZmZddl m Z ddl m Z ddl mZmZddlmZeeZee Zee Zee gee fZee gefZGdddZd ed efd d ZGd ddeZGdddeZGdddeZGdddeZ dededededed eeeeeff ddZ!dS)N)CallableIterableOptionalTuple)InstallationCandidate)Link) path_to_url url_to_path)is_urlc@s>eZdZedeefddZdefddZde fddZ dS) LinkSourcereturncCt)z,Returns the underlying link, if there's one.NotImplementedErrorselfr/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/index/sources.pylinkszLinkSource.linkcCr )z9Candidates found by parsing an archive listing HTML file.rrrrrpage_candidateszLinkSource.page_candidatescCr )z,Links found by specifying archives directly.rrrrr file_linksrzLinkSource.file_linksN) __name__ __module__ __qualname__propertyrrrFoundCandidatesr FoundLinksrrrrrr s r file_urlr cCstj|ddddkS)NF)strictrz text/html) mimetypes guess_type)rrrr _is_html_file#sr"c@sXeZdZdZdededdfddZedee fdd Z de fd d Z de fd d ZdS)_FlatDirectorySourcezLink source specified by ``--find-links=``. This looks the content of the directory, and returns: * ``page_candidates``: Links listed on each HTML file in the directory. * ``file_candidates``: Archives in the directory. candidates_from_pagepathr NcCs||_ttj||_dSN)_candidates_from_pagepathlibPathosr%realpath_path)rr$r%rrr__init__0sz_FlatDirectorySource.__init__cCsdSr&rrrrrr8sz_FlatDirectorySource.linkccs@|jD]}tt|}t|sq|t|EdHqdSr&)r,iterdirrstrr"r'rrr%urlrrrr<s z$_FlatDirectorySource.page_candidatesccs6|jD]}tt|}t|rqt|VqdSr&)r,r.rr/r"rr0rrrrCs  z_FlatDirectorySource.file_links)rrr__doc__CandidatesFromPager/r-rrrrrrrrrrrrr#'s r#c@XeZdZdZdededdfddZedeefdd Z de fd d Z de fd d Z dS)_LocalFileSourceaC``--find-links=`` or ``--[extra-]index-url=``. If a URL is supplied, it must be a ``file:`` URL. If a path is supplied to the option, it is converted to a URL first. This returns: * ``page_candidates``: Links listed on an HTML file. * ``file_candidates``: The non-HTML file. r$rr NcC||_||_dSr&r'_linkrr$rrrrr-U z_LocalFileSource.__init__cC|jSr&r8rrrrr]rz_LocalFileSource.linkccs(t|jjs dS||jEdHdSr&)r"r8r1r'rrrrra z _LocalFileSource.page_candidatesccst|jjr dS|jVdSr&)r"r8r1rrrrrfs  z_LocalFileSource.file_linksrrrr2r3rr-rrrrrrrrrrrr5Ks  r5c@s\eZdZdZdedededdfddZede efd d Z de fd d Z de fd dZdS)_RemoteFileSourcez``--find-links=`` or ``--[extra-]index-url=``. This returns: * ``page_candidates``: Links listed on an HTML file. * ``file_candidates``: The non-HTML file. r$page_validatorrr NcCs||_||_||_dSr&)r'_page_validatorr8)rr$r@rrrrr-us z_RemoteFileSource.__init__cCr;r&r<rrrrrrz_RemoteFileSource.linkccs(||js dS||jEdHdSr&)rAr8r'rrrrrr=z!_RemoteFileSource.page_candidatesccs|jVdSr&r<rrrrrs z_RemoteFileSource.file_links)rrrr2r3 PageValidatorrr-rrrrrrrrrrrr?ls  r?c@r4)_IndexDirectorySourcez``--[extra-]index-url=``. This is treated like a remote URL; ``candidates_from_page`` contains logic for this by appending ``index.html`` to the link. r$rr NcCr6r&r7r9rrrr-r:z_IndexDirectorySource.__init__cCr;r&r<rrrrrrz_IndexDirectorySource.linkccs||jEdHdSr&r7rrrrrsz%_IndexDirectorySource.page_candidatescCsdS)Nrrrrrrrsz _IndexDirectorySource.file_linksr>rrrrrCs rClocationr$r@ expand_dircache_link_parsingc Csd}d}tj|rt|}|}n|dr|}t|}nt|r#|}|dur1d}t||dS|durDt ||t ||dd}||fStj |rd|rVt ||d}||fSt |t ||dd}||fStj|rxt|t ||dd}||fStd||dfS) Nzfile:zVLocation '%s' is ignored: it is either a non-existing path or lacks a specific scheme.)NN)rF)r$r@r)r$r%)r$rz?Location '%s' is ignored: it is neither a file nor a directory.)r*r%existsr startswithr r loggerwarningr?risdirr#rCisfiler5) rDr$r@rErFr%r1msgsourcerrr build_sourcesZ           rO)"loggingr r*r(typingrrrrpip._internal.models.candidaterpip._internal.models.linkrpip._internal.utils.urlsrr pip._internal.vcsr getLoggerrrIrrr3boolrBr r/r"r#r5r?rCrOrrrrsB    $!