Viewing File: /usr/lib/python3.6/site-packages/pip/__pycache__/download.cpython-36.opt-1.pyc

3

ajP@s^ddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZyddlZdZWnek
rdZYnXddlmZddlmZddlZddlmZmZddlmZdd	lmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'dd
l(m)Z)ddl*m+Z+ddl,m-Z-dd
l.m/Z/ddl0m1Z1ddl2m3Z3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:m;Z;ddl<m=Z=m>Z>ddl?m@Z@mAZAddlBmCZCmDZDddlEmFZFddlGmHZHddl9mIZIddlJmKZKddlLmMZMddlNmOZOddlPmQZQdddd d!d"d#d$d%d&d'd(d)g
ZRejSeTZUd*d+ZVGd,d-d-e@ZWGd.d/d/e=ZXGd0d1d1eMZYGd2d3d3e>ZZGd4d5d5e:j[Z\dWd6dZ]ej^d7ej_Z`ej^d8ej_Zad9dZbd:dZcd;d Zdd<d!Zed=d"Zfd>d?Zgd@d$ZhdAd%ZidBdCZjdDdEZkdFdGZldHdIZmdXdJd&ZndYdKd#ZodLdMZpGdNdOdOeQjqZrdZdPd'ZsdQd)ZtdRd(ZudSdTZvdUdVZwdS)[)absolute_importNTF)parse)request)InstallationErrorHashMismatch)PyPI)
splitextrmtreeformat_sizedisplay_path
backup_dirask_path_existsunpack_fileARCHIVE_EXTENSIONSconsumecall_subprocess)auto_decode)check_path_owner)
indent_log)SETUPTOOLS_SHIM)libc_ver)DownloadProgressBarDownloadProgressSpinner)write_delete_marker_file)vcs)requestssix)BaseAdapterHTTPAdapter)AuthBase
HTTPBasicAuth)CONTENT_CHUNK_SIZEResponse)get_netrc_auth)CaseInsensitiveDict)urllib3)CacheControlAdapter)	FileCache)	LockError)
xmlrpc_clientget_file_contentis_urlurl_to_pathpath_to_urlis_archive_fileunpack_vcs_linkunpack_file_url
is_vcs_urlis_file_urlunpack_http_url
unpack_urlparse_content_dispositionsanitize_content_filenamecCsdtjdtjdtjid}|dddkrBtj|dd<n|dddkrtjjd	krntjd
d}ntj}djd
d|D|dd<nB|dddkrtj|dd<n |dddkrtj|dd<tjj	drJddl
m}tt
ddtdddg|j}tt
ddtddgt}|r<||d<|rJ||d<tjj	dr|tjdr|dtjdd|d<tjrtj|jdid<tjrtj|jdid<tjrtj|d<trtjd
d d)krtj|d"<d#j|tj|d*d&d'd(S)+z6
    Return a string representing the user agent.
    pip)nameversionr8)Z	installerpythonimplementationr;ZCPythonr9ZPyPyfinalN.cSsg|]}t|qS)str).0xr?r?/usr/lib/python3.6/download.py
<listcomp>Tszuser_agent.<locals>.<listcomp>ZJythonZ
IronPythonlinuxr)distrocSs|dS)Nr?)rBr?r?rC<lambda>`szuser_agent.<locals>.<lambda>idcSs|dS)NrGr?)rBr?r?rCrHdsliblibcrFdarwinZmacOSsystemreleaseZcpuZopenssl_versionz9{data[installer][name]}/{data[installer][version]} {json},:T)Z
separatorsZ	sort_keys)datajson)rOrP)rQrR)r7__version__platformZpython_versionZpython_implementationsyspypy_version_inforeleaseleveljoin
startswithpip._vendorrFdictfilterzipZlinux_distributionrZmac_verrM
setdefaultrNmachineHAS_TLSversion_infosslZOPENSSL_VERSIONformatrTdumps)rSrXrFZdistro_infosrKr?r?rC
user_agent@sP




rgc@s.eZdZdddZddZddZdd	Zd
S)MultiDomainBasicAuthTcCs||_i|_dS)N)	prompting	passwords)selfrir?r?rC__init__szMultiDomainBasicAuth.__init__cCstj|j}|jjddd}tj|dd|f|dd|_|jj|d\}}|dkrn|j|j\}}|dkr|dkrt	|j}|r|nd\}}|s|r||f|j|<t
|pd|pd|}|jd|j|S)	N@rGrOresponse)NN)NN)
urllib_parseurlparseurlnetlocrsplit
urlunparserjgetparse_credentialsr#r Z
register_hook
handle_401)rkreqparsedrtusernamepasswordZ
netrc_authr?r?rC__call__s&
zMultiDomainBasicAuth.__call__cKs|jdkr|S|js|Stj|j}tjjd|j}t	j	d}|sH|rX||f|j
|j<|j|jj
t|ppd|pvd|j}|jj|f|}|jj||S)Niz
User for %s: z
Password: rn)status_coderirqrrrsrZmovesinputrtgetpassrjcontentrawZrelease_connr rZ
connectionsendhistoryappend)rkrespkwargsr{r|r}rzZnew_respr?r?rCrys


zMultiDomainBasicAuth.handle_401cCs8d|kr4|jddd}d|kr,|jddS|dfSdS)NrmrGrrR)NN)rusplit)rkrtZuserinfor?r?rCrxsz&MultiDomainBasicAuth.parse_credentialsN)T)__name__
__module____qualname__rlr~ryrxr?r?r?rCrhs
!"rhc@seZdZdddZddZdS)LocalFSAdapterNc
Cst|j}t}d|_|j|_ytj|}	Wn.tk
rZ}
zd|_|
|_WYdd}
~
XnPXtj	j
|	jdd}tj
|dp~d}t||	j|d|_t|d|_|jj|_|S)	NiT)Zusegmtrz
text/plain)zContent-TypezContent-Lengthz
Last-Modifiedrb)r,rsr"rosstatOSErrorremailZutilsZ
formatdatest_mtime	mimetypes
guess_typer$st_sizeheadersopenclose)
rkrstreamtimeoutverifycertZproxiespathnamerZstatsexcZmodifiedcontent_typer?r?rCrs$

zLocalFSAdapter.sendcCsdS)Nr?)rkr?r?rCrszLocalFSAdapter.close)NNNNN)rrrrrr?r?r?rCrs
rcsDeZdZdZfddZfddZfddZfdd	ZZS)

SafeFileCachezw
    A file based cache which is safe to use even when the target directory may
    not be accessible or writable.
    cs4tt|j||t|js0tjd|jd|_dS)NzThe directory '%s' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.)superrrlr	directoryloggerwarning)rkargsr)	__class__r?rCrls
zSafeFileCache.__init__c
s@|jdkrdSytt|j||Stttfk
r:YnXdS)N)rrrrwr(rIOError)rkrr)rr?rCrws
zSafeFileCache.getc
s@|jdkrdSytt|j||Stttfk
r:YnXdS)N)rrrsetr(rr)rkrr)rr?rCrs
zSafeFileCache.setc
s@|jdkrdSytt|j||Stttfk
r:YnXdS)N)rrrdeleter(rr)rkrr)rr?rCr)s
zSafeFileCache.delete)	rrr__doc__rlrwrr
__classcell__r?r?)rrCrs


rc@seZdZddZdS)InsecureHTTPAdaptercCsd|_d|_dS)NZ	CERT_NONE)Z	cert_reqsZca_certs)rkZconnrsrrr?r?rCcert_verify9szInsecureHTTPAdapter.cert_verifyN)rrrrr?r?r?rCr7srcs,eZdZdZfddZfddZZS)
PipSessionNc	s|jdd}|jdd}|jdg}tt|j||t|jd<t|_tj	|dgdd}|rvt
t|d	d
|d}n
t|d}t
|d}|jd
||jd||jdtx|D]}|jdj||qWdS)Nretriesrcacheinsecure_hostsz
User-Agentig?)ZtotalZstatus_forcelistZbackoff_factorT)Zuse_dir_lock)rmax_retries)rzhttps://zhttp://zfile://zhttps://{0}/)poprrrlrgrrhZauthr%ZRetryr&rrrZmountrre)	rkrrrrrZsecure_adapterZinsecure_adapterhost)rr?rCrlBs*




zPipSession.__init__cs(|jd|jtt|j||f||S)Nr)r`rrrr)rkmethodrsrr)rr?rCr~szPipSession.request)rrrrrlrrr?r?)rrCr>s<rc
CsL|dkrtdtj|}|r|jdj}|dkrR|rR|jdrRtd||f|dkr|jddd}|jdd	}t	j
|}|r|jdd|jd
dd}tj|}|jd	rd	|j
d	}|}n|j|}|j|j|jfSy&t|d}t|j}WdQRXWn4tk
rB}	ztdt|	WYdd}	~	XnX||fS)
zGets the content of a file; it may be a filename, file: URL, or
    http: URL.  Returns (location, content).  Content is unicode.NzAget_file_content() missing 1 required keyword argument: 'session'rGfilehttpz6Requirements file %s references URL %s, which is localrR\/|rz$Could not open requirements file: %s)	TypeError
_scheme_researchgrouplowerr[rrreplace_url_slash_drive_rematchrqZunquotelstriprwraise_for_statusrstextrrreadrr@)
rsZ
comes_fromsessionrschemepathrfrrr?r?rCr*s>





 z^(http|https|file):z/*([a-z])\|cCs6d|krdS|jdddj}|ddddgtjkS)	z)Returns true if the name looks like a URLrRFrGrrZhttpsrZftp)rrrZall_schemes)r8rr?r?rCr+scCs2tj|\}}}}}|r d|}tj||}|S)z(
    Convert a file: URL to a path.
    z\\)rqZurlspliturllib_requestZurl2pathname)rs_rtrr?r?rCr,s
cCs*tjjtjj|}tjdtj|}|S)zh
    Convert a path to a file: URL.  The path will be made absolute and have
    quoted path parts.
    zfile:)rrnormpathabspathrqZurljoinrZpathname2url)rrsr?r?rCr-scCs t|dj}|tkrdSdS)z9Return True if `name` is a considered as an archive file.rGTF)rrr)r8extr?r?rCr.scCst|}|j|dS)N)_get_used_vcs_backendunpack)linklocationvcs_backendr?r?rCr/scCs.x(tjD]}|j|jkr||j}|SqWdS)N)rZbackendsrZschemesrs)rZbackendrr?r?rCrs
rcCstt|S)N)boolr)rr?r?rCr1scCs|jjjdS)Nzfile:)rsrr[)rr?r?rCr2scCst|j}tjj|S)zReturn whether a file:// Link points to a directory.

    ``link`` must not have any other scheme but file://. Call is_file_url()
    first.

    )r,url_without_fragmentrrisdir)r	link_pathr?r?rC
is_dir_urls
rcOs|S)Nr?)iterablerrr?r?rC_progress_indicatorsrc

sLytjd}Wntttfk
r0d}YnXtdd}tjtj	krRd}n&|r\d}n|dkrjd}n|std}nd}|j
}fdd	}fd
d}	t}
|jt
jkr|}n|j}|r|rtjd|t|t|d
j}
ntjd|tj}
n |rtjd|ntjd|tjd||	|
|tt}|r@|j|nt|dS)Nzcontent-lengthrZ
from_cacheF(iTc3s\y$xjj|ddD]
}|VqWWn2tk
rVxjj|}|sHP|Vq6WYnXdS)NF)Zdecode_content)rrAttributeErrorr)Z
chunk_sizechunk)rr?rC	resp_readsz _download_url.<locals>.resp_readc3s"x|D]}j||VqWdS)N)write)Zchunksr)content_filer?rCwritten_chunks;s

z%_download_url.<locals>.written_chunkszDownloading %s (%s))maxzDownloading %szUsing cached %szDownloading from URL %si@)intr
ValueErrorKeyErrorrgetattrrZgetEffectiveLevelloggingINFOshow_urlrrtrrinfor
riterrdebugr!Zcheck_against_chunksr)
rrrhashesZtotal_lengthZcached_respZ
show_progressrrrZprogress_indicatorrsZdownloaded_chunksr?)rrrC
_download_urlsL
%
rcCsd}tjj||j}tjj|rtdt|d}|dkr@d}nj|dkrdtjdt|tj	|nF|dkrt
|}tjd	t|t|tj||n|dkrt
jd
|rtj||tjdt|dS)NTz8The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)abortiwbaFzDeleting %szBacking up %s to %srGzSaved %s)rrrrrp)rrrZfilenameexistsr
rrrremovershutilZmoverWexitcopyr)rrrrZdownload_locationroZ	dest_filer?r?rC
_copy_fileas.

rc	Cs|dkrtdtjdd}d}|r0t|||}|rH|}tj|d}nt||||\}}t|||||r~|r~t||||st	j
|t|dS)Nz@unpack_http_url() missing 1 required keyword argument: 'session'z-unpackzpip-r)rtempfileZmkdtemp_check_download_dirrr_download_http_urlrrrunlinkr	)	rrdownload_dirrrtemp_diralready_downloaded_path	from_pathrr?r?rCr3|s,


cCst|j}t|rHtjj|r&t|tj||dd|rDt	j
ddS|rV|j|d}|rjt|||}|rt|}n|}t
j|d}t|||||r|rt|||dS)zUnpack link into location.

    If download_dir is provided and link points to a file, make a copy
    of the link file inside download_dir.
    T)Zsymlinksz*Link is a directory, ignoring download_dirNr)r,rrrrrr	rZcopytreerrcheck_against_pathrrrrr)rrrrrrrrr?r?rCr0s,



c
Cstjj|rt|d}tjg}|jd|jt||jd|d|g7}tj	d|t
t||ddWdQRXtjj|tj
|d	}tj	d
||t||ddddS)zCopy distribution files in `link_path` to `location`.

    Invoked when user requests to install a local directory. E.g.:

        pip install .
        pip install ~/dev/git-repos/python-prompt-toolkit

    zsetup.pyz-csdistz
--dist-dirzRunning setup.py sdist for %sF)cwdZshow_stdoutNrzUnpacking sdist %s into %s)rr)rrrr	rW
executablerrrrrrrZlistdirr)rrZsetup_pyZ
sdist_argsrr?r?rC_copy_dist_from_dirs

r
c@s$eZdZdZdddZd	ddZdS)
PipXmlrpcTransportzRProvide a `xmlrpclib.Transport` implementation via a `PipSession`
    object.
    FcCs*tjj||tj|}|j|_||_dS)N)r)	Transportrlrqrrr_scheme_session)rkZ	index_urlrZuse_datetimeZindex_partsr?r?rCrls
zPipXmlrpcTransport.__init__c
Cs|j||dddf}tj|}y6ddi}|jj|||dd}|j||_|j|jSt	j
k
r}	ztjd|	j
j|WYdd}	~	XnXdS)NzContent-Typeztext/xmlT)rSrrzHTTP error %s while getting %s)r
rqrvrZpostrverboseZparse_responserr	HTTPErrorrcriticalror)
rkrZhandlerZrequest_bodyrpartsrsrrorr?r?rCrs


zPipXmlrpcTransport.requestN)F)F)rrrrrlrr?r?r?rCrs
rcCs^t|rt||n:t|r.t||||dn |dkr<t}t|||||d|rZt|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.
    )rN)r1r/r2r0rr3r)rrrZ
only_downloadrrr?r?rCr4scCstjj|S)zK 
    Sanitize the "filename" value from a Content-Disposition header.
    )rrbasename)rr?r?rCr6;scCs,tj|\}}|jd}|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_headerrwr6)content_dispositionZdefault_filenameZ_typeZparamsrr?r?rCr5Cs

c
Cs*|jjddd}y |j|ddidd}|jWn8tjk
rj}ztjd|jj	|WYd	d	}~XnX|j
jd
d}|j}|j
jd}	|	rt|	|}t
|d}
|
stj|}
|
r||
7}|
r|j|jkrtjj
|jd}
|
r||
7}tjj||}t|d
}t||||Wd	QRX||fS)z6Download link url into temp_dir using provided session#rGrzAccept-EncodingZidentityT)rrzHTTP error %s while getting %sNzcontent-typernzcontent-dispositionwb)rsrrwrrrrrrorrrr5rrZguess_extensionrrrZrr)
rrrrZ
target_urlrrrrrrZ	file_pathrr?r?rCrRs:

rcCsntjj||j}tjj|rjtjd||rfy|j|Wn*tk
rdtj	d|tj
|dSX|SdS)z Check download_dir for previously downloaded file with correct hash
        If a correct file is found return its path else None
    zFile was already downloaded %sz;Previously-downloaded file %s has bad hash. Re-downloading.N)rrrZrrrrrrrr)rrrZ
download_pathr?r?rCrs
r)NN)NNN)NN)NFNN)xZ
__future__rrZemail.utilsrrrTrrrrVrerrWrrdrbImportErrorZpip._vendor.six.moves.urllibrrqrrr7Zpip.exceptionsrrZ
pip.modelsrZ	pip.utilsrr	r
rrr
rrrrZpip.utils.encodingrZpip.utils.filesystemrZpip.utils.loggingrZpip.utils.setuptools_buildrZpip.utils.glibcrZpip.utils.uirrZ
pip.locationsrZpip.vcsrr\rrZpip._vendor.requests.adaptersrrZpip._vendor.requests.authrr Zpip._vendor.requests.modelsr!r"Zpip._vendor.requests.utilsr#Zpip._vendor.requests.structuresr$r%Zpip._vendor.cachecontrolr&Zpip._vendor.cachecontrol.cachesr'Zpip._vendor.lockfiler(Zpip._vendor.six.movesr)__all__Z	getLoggerrrrgrhrrrZSessionrr*compileIrrr+r,r-r.r/rr1r2rrrrr3r0r
rrr4r6r5rrr?r?r?rC<module>s
0
BR!BH
)
`
&
0$
&8
Back to Directory File Manager