o Ec@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.NotImplementedErrorselfrN/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) mimetypesZ 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!rr/rrrrCs  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%r7rrrrr]rz_LocalFileSource.linkccs(t|jjs dS||jEdHdSr%)r!r7r0r&rrrrra z _LocalFileSource.page_candidatesccst|jjr dS|jVdSr%)r!r7r0rrrrrfs  z_LocalFileSource.file_linksrrrr1r2rr,rrrrrrrrrrrr4Ks  r4c@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_validatorr7)rr#r?rrrrr,us z_RemoteFileSource.__init__cCr:r%r;rrrrrrz_RemoteFileSource.linkccs(||js dS||jEdHdSr%)r@r7r&rrrrrr<z!_RemoteFileSource.page_candidatesccs|jVdSr%r;rrrrrs z_RemoteFileSource.file_links)rrrr1r2 PageValidatorrr,rrrrrrrrrrrr>ls  r>c@r3)_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 NcCr5r%r6r8rrrr,r9z_IndexDirectorySource.__init__cCr:r%r;rrrrrrz_IndexDirectorySource.linkccs||jEdHdSr%r6rrrrrsz%_IndexDirectorySource.page_candidatescCsdS)Nrrrrrrrsz _IndexDirectorySource.file_linksr=rrrrrBs rBlocationr#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)rE)r#r?r)r#r$)r#rz?Location '%s' is ignored: it is neither a file nor a directory.)r)r$existsr startswithr r loggerZwarningr>risdirr"rBisfiler4) rCr#r?rDrEr$r0msgsourcerrr build_sourcesZ           rM)"Zloggingr r)r'typingrrrrZpip._internal.models.candidaterZpip._internal.models.linkrZpip._internal.utils.urlsrr Zpip._internal.vcsr Z getLoggerrrHrrr2boolrAr r.r!r"r4r>rBrMrrrrsB    $!