U ÀÒ.eEQã@s˜ddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z ddlmZddlmZddlmZmZddlmZdd lmZdd lmZdd lmZdd lmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'dd l(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3e+�rêddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:ddl;mZ>ddl?m@Z@ddlAmBZBe�r²ed0d „ZSd1d2„ZTd3d4„ZUd?d5d„ZVd@d6d!„ZWd7d#„ZXd8d"„ZYd9d:„ZZd;d<„Z[dS)Aé)Úabsolute_importN)Úrequests)ÚCONTENT_CHUNK_SIZEÚResponse)ÚPY2)Úparse)Ú HashMismatchÚInstallationError)ÚPyPI)Ú PipSession)Ú auto_decode)Ú copy2_fixed) Úask_path_existsÚ backup_dirÚconsumeÚ display_pathÚ format_sizeÚhide_urlÚpath_to_displayÚrmtreeÚsplitext)Ú TempDirectory)ÚMYPY_CHECK_RUNNING)ÚDownloadProgressProvider)Ú unpack_file)Úget_url_scheme)Úvcs)ÚIOÚCallableÚListÚOptionalÚTextÚTuple)Ú TypedDict)ÚLink)ÚHashes)ÚVersionControlÚCopytreeKwargs©ÚignoreÚsymlinksF)Ztotal)Ú copy_functionr)Zignore_dangling_symlinksr*Úget_file_contentÚunpack_vcs_linkÚunpack_file_urlÚunpack_http_urlÚ unpack_urlÚparse_content_dispositionÚsanitize_content_filenamec Cs6|dkrtdƒ‚t|ƒ}|dkr>| |¡}| ¡|j|jfS|dkrÒ|rd| d¡rdtd||fƒ‚| dd¡d}|  d d ¡}t   |¡}|r¬|  d¡d| d d¡d}t  |¡}| d ¡rÎd | d ¡}|}z&t|d ƒ�}t| ¡ƒ}W5QRXWn4tk �r,} ztd t| ƒƒ‚W5d} ~ XYnX||fS)a*Gets the content of a file; it may be a filename, file: URL, or http: URL. Returns (location, content). Content is unicode. :param url: File path or url. :param comes_from: Origin description of requirements. :param session: Instance of pip.download.PipSession. NzAget_file_content() missing 1 required keyword argument: 'session')ÚhttpZhttpsÚfiler3z6Requirements file %s references URL %s, which is localú:éú\ú/ú|Úrbz$Could not open requirements file: %s)Ú TypeErrorrÚgetÚraise_for_statusÚurlÚtextÚ startswithr ÚsplitÚreplaceÚ_url_slash_drive_reÚmatchÚgroupÚ urllib_parseZunquoteÚlstripÚopenr ÚreadÚIOErrorÚstr) r>Z comes_fromÚsessionÚschemeÚrespÚpathrDÚfZcontentÚexc©rRú:/usr/lib/python3.8/site-packages/pip/_internal/download.pyr,UsB ÿ  ÿÿ      ÿz /*([a-z])\|cCs,t|ƒ}|dk st‚|j|t|jƒd�dS)N)r>)Ú_get_used_vcs_backendÚAssertionErrorÚunpackrr>)ÚlinkÚlocationÚ vcs_backendrRrRrSr-ˆs cCs$tjD]}|j|jkr|SqdS)z1 Return a VersionControl object or None. N)rZbackendsrMZschemes)rWrYrRrRrSrT�s   rTcOs|S©NrR)ÚiterableÚargsÚkwargsrRrRrSÚ_progress_indicatoršsr^c s6ztˆjdƒ}Wntttfk r0d}YnXtˆddƒ}t ¡tj krRd}n&|r\d}n|dkrjd}n|std}nd}|j }‡fdd„} ‡fd d „} t } |j t j kr¬|} n|j} |rèt||d �} |rÚt d | t|ƒ¡n t d | ¡n|rút d| ¡n t d | ¡| | | tƒtƒƒ} |�r*| | ¡nt| ƒdS)Nzcontent-lengthrZ from_cacheFi@œTc3sTz ˆjj|dd�D] }|VqWn.tk rNˆj |¡}|sBqJ|Vq0YnXdS)NF)Zdecode_content)ÚrawÚstreamÚAttributeErrorrI)Z chunk_sizeÚchunk)rNrRrSÚ resp_read¹sè   z _download_url..resp_readc3s|D]}ˆ |¡|VqdSrZ)Úwrite)Zchunksrb)Ú content_filerRrSÚwritten_chunksÞs z%_download_url..written_chunks)ÚmaxzDownloading %s (%s)zDownloading %szUsing cached %s)ÚintÚheadersÚ ValueErrorÚKeyErrorr;ÚgetattrÚloggerZgetEffectiveLevelÚloggingÚINFOÚshow_urlr^Znetlocr Zurl_without_fragmentrÚinforrZcheck_against_chunksr)rNrWreÚhashesÚ progress_barZ total_lengthZ cached_respZ show_progressrprcrfZprogress_indicatorr>Zdownloaded_chunksrR)rerNrSÚ _download_urlžsP   %  ÿ þÿ rtcCsÎd}tj ||j¡}tj |¡rªtdt|ƒdƒ}|dkr@d}nj|dkrdt dt|ƒ¡t  |¡nF|dkr˜t |ƒ}t d t|ƒt|ƒ¡t   ||¡n|d krªt  d ¡|rÊt  ||¡t d t|ƒ¡dS) NTz8The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)abort)ÚiÚwÚbÚaruFrvz Deleting %srwzBacking up %s to %srxéÿÿÿÿzSaved %s)ÚosrOÚjoinÚfilenameÚexistsrrrmÚwarningÚremoverÚshutilZmoveÚsysÚexitÚcopyrq)r|rXrWrƒZdownload_locationÚresponseZ dest_filerRrRrSÚ _copy_files6 ÿþ ý  r…Úonc Csš|dkrtdƒ‚tdd��v}d}|r0t|||ƒ}|rH|}t |¡d} nt|||j||ƒ\}} t||| ƒ|r~|s~t|||ƒ|sŒt   |¡W5QRXdS)Nz@unpack_http_url() missing 1 required keyword argument: 'session'rV)Zkindr) r;rÚ_check_download_dirÚ mimetypesÚ guess_typeÚ_download_http_urlrOrr…rzÚunlink) rWrXÚ download_dirrLrrrsÚtemp_dirÚalready_downloaded_pathÚ from_pathÚ content_typerRrRrSr/s2 ÿ þü  c CsTzt||ƒWn@tjk rN}z t dt|ƒt|ƒt|ƒ¡W5d}~XYnXdS)zÆCopying special files is not supported, but as a convenience to users we skip errors copying them. This supports tools that may create e.g. socket files in the project source directory. z>Ignoring special file error '%s' encountered copying %s to %s.N)r r€ZSpecialFileErrorrmr~rKr)ÚsrcÚdestÚerRrRrSÚ_copy2_ignoring_special_filesJsür”cs`tj |¡}tj |¡‰tj |¡‰‡‡‡fdd„}t|dd�}tsLt|d<tj ˆ|f|ŽdS)Ncs6g}|ˆkr|ddg7}tj |¡ˆkr2|ˆg7}|S)Nz.toxz.nox)rzrOÚabspath)ÚdÚnamesZskipped©ÚsourceZtarget_basenameZtarget_dirnamerRrSr)es   z!_copy_source_tree..ignoreTr(r+) rzrOr•ÚbasenameÚdirnameÚdictrr”r€Zcopytree)r™ÚtargetZtarget_abspathr)r]rRr˜rSÚ_copy_source_tree_s    ržcCs |j}| ¡r>tj |¡r"t|ƒt||ƒ|r:t d¡dS|rL|  |¡d}|r`t |||ƒ}|rj|}n|}t   |¡d}t |||ƒ|rœ|sœt|||ƒdS)z‘Unpack link into location. If download_dir is provided and link points to a file, make a copy of the link file inside download_dir. z*Link is a directory, ignoring download_dirNr)Ú file_pathZis_existing_dirrzrOÚisdirrržrmrqÚcheck_against_pathr‡rˆr‰rr…)rWrXrŒrrZ link_pathrŽr�r�rRrRrSr.~s.     þ cCsP|jrt||ƒn:|jr*t||||d�n"|dkr8tƒ}t||||||d�dS)avUnpack link. If link is a VCS link: if only_download, export into download_dir and ignore location else unpack into location for other types of link: - unpack into location - if download_dir, copy the file into download_dir - if only_download, mark location for deletion :param hashes: A Hashes object, one of whose embedded hashes must match, or HashMismatch will be raised. If the Hashes is empty, no matches are required, and unhashable types of requirements (like VCS ones, which would ordinarily raise HashUnsupported) are allowed. )rrN)rrrs)Zis_vcsr-Úis_filer.r r/)rWrXrŒrLrrrsrRrRrSr0³s úcCs tj |¡S)zJ Sanitize the "filename" value from a Content-Disposition header. )rzrOrš)r|rRrRrSr2áscCs,t |¡\}}| d¡}|r$t|ƒ}|p*|S)zƒ Parse the "filename" value from a Content-Disposition header, and return the default filename if the result is empty. r|)ÚcgiZ parse_headerr<r2)Úcontent_dispositionZdefault_filenameZ_typeZparamsr|rRrRrSr1és  c Cs*|j dd¡d}z |j|ddidd�}| ¡Wn8tjk rj}zt d|jj |¡‚W5d }~XYnX|j  d d ¡}|j } |j  d ¡} | ršt | | ƒ} t | ƒd} | sÀt |¡} | rÀ| | 7} | sî|j|jkrîtj  |j¡d} | rî| | 7} tj || ¡} t| d ƒ�} t||| ||ƒW5QRX| |fS)z6Download link url into temp_dir using provided sessionú#r6rzAccept-EncodingZidentityT)rir`zHTTP error %s while getting %sNz content-typeÚzcontent-dispositionÚwb)r>rAr<r=rZ HTTPErrorrmZcriticalr„Z status_coderir|r1rrˆZguess_extensionrzrOr{rHrt)rWrLr�rrrsZ target_urlrNrQr�r|r¤ZextrŸrerRrRrSrŠøsB ê ÿ     rŠcCsptj ||j¡}tj |¡s dSt d|¡|rlz| |¡Wn,tk rjt  d|¡t  |¡YdSX|S)z† Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None NzFile was already downloaded %sz;Previously-downloaded file %s has bad hash. Re-downloading.) rzrOr{r|r}rmrqr¡rr~r‹)rWrŒrrZ download_pathrRrRrSr‡7s  ý r‡)NN)NNNr†)NN)NNNr†)\Z __future__rr£rnrˆrzÚrer€r�Z pip._vendorrZpip._vendor.requests.modelsrrZpip._vendor.sixrZpip._vendor.six.moves.urllibrrFZpip._internal.exceptionsrr Zpip._internal.models.indexr Zpip._internal.network.sessionr Zpip._internal.utils.encodingr Zpip._internal.utils.filesystemr Zpip._internal.utils.miscrrrrrrrrrZpip._internal.utils.temp_dirrZpip._internal.utils.typingrZpip._internal.utils.uirZpip._internal.utils.unpackingrZpip._internal.utils.urlsrZpip._internal.vcsrÚtypingrrrr r!r"Zmypy_extensionsr#Zpip._internal.models.linkr$Zpip._internal.utils.hashesr%Z pip._internal.vcs.versioncontrolr&rKÚboolr'Ú__all__Z getLoggerÚ__name__rmr,ÚcompileÚIrCr-rTr^rtr…r/r”ržr.r0r2r1rŠr‡rRrRrRrSÚs¢        ,           þú üø ü  0 dú -"ü 8ú .?