U 巀g! @shddlZddlZddlZddlmZddlmZmZmZm Z m Z m Z ddl m Z mZmZmZmZddlmZddlmZddlmZmZddlmZeeZeeZeeZeegeefZ eege!fZ"Gd d d Z#e$e!d d d Z%GdddZ&Gddde#Z'Gddde#Z(Gddde#Z)Gddde#Z*e$e e"e!e!e$e e e$e e#fdddZ+dS)N) defaultdict)CallableDictIterableListOptionalTuple)InvalidSdistFilenameInvalidWheelFilenamecanonicalize_nameparse_sdist_filenameparse_wheel_filename)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.NNotImplementedErrorselfrI/opt/hc_python/lib/python3.8/site-packages/pip/_internal/index/sources.pylinkszLinkSource.linkcCs tdS)z9Candidates found by parsing an archive listing HTML file.Nrrrrrpage_candidates"szLinkSource.page_candidatescCs tdS)z,Links found by specifying archives directly.Nrrrrr file_links&szLinkSource.file_linksN) __name__ __module__ __qualname__propertyrrrFoundCandidatesr FoundLinksrrrrrrsr)file_urlrcCstj|ddddkS)NF)strictrz text/html) mimetypes guess_type)r%rrr _is_html_file+sr)c@sbeZdZdZeddddZddddZeeedd d Z ee eeefdd d Z dS) _FlatDirectoryToUrlsz"Scans directory and caches resultsN)pathrcCs ||_g|_tt|_d|_dS)NF)_path_page_candidatesrlist_project_name_to_urls_scanned_directory)rr+rrr__init__2s z_FlatDirectoryToUrls.__init__rc Cst|jD]}t|j}t|r0|j|q zt|j d}WnBt k rzt |j d}Wnt k r~YYq YnXYnX|j ||q d|_dS)zrScans directory once and populates both page_candidates and project_name_to_urls at the same time rTN)osscandirr,rr+r)r-appendr namer r r r/r0)rentryurlproject_filenamerrr_scan_directory8s  z$_FlatDirectoryToUrls._scan_directorycCs|js||jSN)r0r9r-rrrrrOsz$_FlatDirectoryToUrls.page_candidatescCs|js||jSr:)r0r9r/rrrrproject_name_to_urlsVsz)_FlatDirectoryToUrls.project_name_to_urls) rr r!__doc__strr1r9r"rrrr;rrrrr*/sr*c@sleZdZUdZiZeeefed<e eeddddZ e e e ddd Zedd d Zedd 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. _paths_to_urlsN)candidates_from_pager+ project_namercCsD||_t||_||jkr(|j||_nt|d|_|j|j|<dS)N)r+)_candidates_from_pager _project_namer? _path_to_urlsr*)rr@r+rArrrr1is    z_FlatDirectorySource.__init__rcCsdSr:rrrrrrysz_FlatDirectorySource.linkccs&|jjD]}|t|EdHqdSr:)rDrrBrrr7rrrr}s z$_FlatDirectorySource.page_candidatesccs"|jj|jD]}t|VqdSr:)rDr;rCrrErrrrsz_FlatDirectorySource.file_links)rr r!r<r?rr=r*__annotations__CandidatesFromPager1r"rrrr#rr$rrrrrr>^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@rrcCs||_||_dSr:rB_linkrr@rrrrr1sz_LocalFileSource.__init__rcCs|jSr:rKrrrrrsz_LocalFileSource.linkccs&t|jjsdS||jEdHdSr:)r)rKr7rBrrrrrs z _LocalFileSource.page_candidatesccst|jjrdS|jVdSr:)r)rKr7rrrrrs z_LocalFileSource.file_linksrr r!r<rGrr1r"rrr#rr$rrrrrrHs  rHc@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_validatorrrcCs||_||_||_dSr:)rB_page_validatorrK)rr@rPrrrrr1sz_RemoteFileSource.__init__rcCs|jSr:rMrrrrrsz_RemoteFileSource.linkccs&||jsdS||jEdHdSr:)rQrKrBrrrrrs z!_RemoteFileSource.page_candidatesccs |jVdSr:rMrrrrrsz_RemoteFileSource.file_links)rr r!r<rG PageValidatorrr1r"rrr#rr$rrrrrrOs  rOc@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. NrIcCs||_||_dSr:rJrLrrrr1sz_IndexDirectorySource.__init__rcCs|jSr:rMrrrrrsz_IndexDirectorySource.linkccs||jEdHdSr:rJrrrrrsz%_IndexDirectorySource.page_candidatescCsdS)Nrrrrrrrsz _IndexDirectorySource.file_linksrNrrrrrSs rS)locationr@rP expand_dircache_link_parsingrArc Csd}d}tj|r"t|}|}n$|dr:|}t|}n t|rF|}|dkrbd}t||dS|dkrt ||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)rV)r@rPr)r@r+rA)r@rz?Location '%s' is ignored: it is neither a file nor a directory.)r2r+existsr startswithrrloggerwarningrOrisdirr>rSisfilerH) rTr@rPrUrVrAr+r7msgsourcerrr build_sourcesZ          r_),loggingr'r2 collectionsrtypingrrrrrrZpip._vendor.packaging.utilsr r r r r pip._internal.models.candidaterpip._internal.models.linkrpip._internal.utils.urlsrrpip._internal.vcsr getLoggerrrYr#r$rGboolrRrr=r)r*r>rHrOrSr_rrrrs:      /(!