a  ze @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]/opt/bitninja-python-dojo/embedded/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) mimetypes 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%r6rrrrr]sz_LocalFileSource.linkccs&t|jjsdS||jEdHdSr%)r!r6r0r&rrrrras z _LocalFileSource.page_candidatesccst|jjrdS|jVdSr%)r!r6r0rrrrrfs z_LocalFileSource.file_linksrrrr1r2rr,rrrrrrrrrrrr3Ks  r3c@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_validatorr6)rr#r;rrrrr,usz_RemoteFileSource.__init__r cCs|jSr%r8rrrrrsz_RemoteFileSource.linkccs&||jsdS||jEdHdSr%)r<r6r&rrrrrs z!_RemoteFileSource.page_candidatesccs |jVdSr%r8rrrrrsz_RemoteFileSource.file_links)rrrr1r2 PageValidatorrr,rrrrrrrrrrrr:ls  r:c@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. Nr4cCs||_||_dSr%r5r7rrrr,sz_IndexDirectorySource.__init__r cCs|jSr%r8rrrrrsz_IndexDirectorySource.linkccs||jEdHdSr%r5rrrrrsz%_IndexDirectorySource.page_candidatescCsdS)Nrrrrrrrsz _IndexDirectorySource.file_linksr9rrrrr>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)rA)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"r>isfiler3) r?r#r;r@rAr$r0msgsourcerrr build_sourcesX          rJ)"loggingrr)r'typingrrrrpip._internal.models.candidaterpip._internal.models.linkrpip._internal.utils.urlsrr pip._internal.vcsr getLoggerrrDrrr2boolr=r r.r!r"r3r:r>rJrrrrs4    $!