a [f @s0ddlZddlZddlZddlZddlmZmZmZmZddl m Z ddl m Z ddl mZmZddlmZeeZee Zee Zee gee fZee gefZGdddZeed d d ZGd d d eZGdddeZGdddeZGdddeZ eeeeeeeeeefdddZ!dS)N)CallableIterableOptionalTuple)InstallationCandidate)Link) path_to_url url_to_path)is_urlc@s>eZdZeeedddZedddZe dddZ dS) LinkSourcereturncCs tdS)z,Returns the underlying link, if there's one.NNotImplementedErrorselfr?/usr/lib/python3.9/site-packages/pip/_internal/index/sources.pylinkszLinkSource.linkcCs tdS)z9Candidates found by parsing an archive listing HTML file.Nrrrrrpage_candidatesszLinkSource.page_candidatescCs tdS)z,Links found by specifying archives directly.Nrrrrr file_linksszLinkSource.file_linksN) __name__ __module__ __qualname__propertyrrrFoundCandidatesr FoundLinksrrrrrr sr )file_urlr cCstj|ddddkS)NF)strictrz text/html) mimetypesZ guess_type)rrrr _is_html_file#sr c@sTeZdZdZeeddddZeee dddZ e dd d Z e dd 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. N)candidates_from_pagepathr cCs||_ttj||_dSN)_candidates_from_pagepathlibPathosr#realpath_path)rr"r#rrr__init__0sz_FlatDirectorySource.__init__r cCsdSr$rrrrrr8sz_FlatDirectorySource.linkccs>|jD].}tt|}t|s$q |t|EdHq dSr$)r*iterdirrstrr r%rrr#urlrrrr<s  z$_FlatDirectorySource.page_candidatesccs4|jD]$}tt|}t|r$q t|Vq dSr$)r*r,rr-r rr.rrrrCs  z_FlatDirectorySource.file_links)rrr__doc__CandidatesFromPager-r+rrrrrrrrrrrrr!'s  r!c@sTeZdZdZeeddddZeeedddZ e dd d Z e dd 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. Nr"rr cCs||_||_dSr$r%_linkrr"rrrrr+Usz_LocalFileSource.__init__r cCs|jSr$r5rrrrr]sz_LocalFileSource.linkccs&t|jjsdS||jEdHdSr$)r r5r/r%rrrrras z _LocalFileSource.page_candidatesccst|jjrdS|jVdSr$)r r5r/rrrrrfs z_LocalFileSource.file_linksrrrr0r1rr+rrrrrrrrrrrr2Ks  r2c@sVeZdZdZeeeddddZee edddZ e dd d Z e dd d ZdS) _RemoteFileSourcez``--find-links=`` or ``--[extra-]index-url=``. This returns: * ``page_candidates``: Links listed on an HTML file. * ``file_candidates``: The non-HTML file. N)r"page_validatorrr cCs||_||_||_dSr$)r%_page_validatorr5)rr"r:rrrrr+usz_RemoteFileSource.__init__r cCs|jSr$r7rrrrrsz_RemoteFileSource.linkccs&||jsdS||jEdHdSr$)r;r5r%rrrrrs z!_RemoteFileSource.page_candidatesccs |jVdSr$r7rrrrrsz_RemoteFileSource.file_links)rrrr0r1 PageValidatorrr+rrrrrrrrrrrr9ls  r9c@sTeZdZdZeeddddZeeedddZ e dd d Z e dd d Z dS) _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. Nr3cCs||_||_dSr$r4r6rrrr+sz_IndexDirectorySource.__init__r cCs|jSr$r7rrrrrsz_IndexDirectorySource.linkccs||jEdHdSr$r4rrrrrsz%_IndexDirectorySource.page_candidatescCsdS)Nrrrrrrrsz _IndexDirectorySource.file_linksr8rrrrr=s r=)locationr"r: expand_dircache_link_parsingr c Csd}d}tj|r"t|}|}n$|dr:|}t|}n t|rF|}|durbd}t||dS|durt ||t ||dd}||fStj |r|rt ||d}nt |t ||dd}||fStj|rt|t ||dd}||fStd||dfS) Nzfile:zVLocation '%s' is ignored: it is either a non-existing path or lacks a specific scheme.)NN)r@)r"r:r)r"r#)r"rz?Location '%s' is ignored: it is neither a file nor a directory.)r(r#existsr startswithr r loggerZwarningr9risdirr!r=isfiler2) r>r"r:r?r@r#r/msgsourcerrr build_sourcesX          rH)"Zloggingrr(r&typingrrrrZpip._internal.models.candidaterZpip._internal.models.linkrZpip._internal.utils.urlsrr Zpip._internal.vcsr Z getLoggerrrCrrr1boolr<r r-r r!r2r9r=rHrrrrs4    $!