AlkantarClanX12

Your IP : 3.135.200.121


Current Path : /usr/lib/python3.6/site-packages/pip/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/pip/__pycache__/download.cpython-36.pyc

3

�PfO��@s^ddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZyddlZdZWnek
r�dZYnXddlmZddlmZddlZddlmZmZddlmZdd	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
ZRejSeT�ZUd*d+�ZVGd,d-�d-e@�ZWGd.d/�d/e=�ZXGd0d1�d1eM�ZYGd2d3�d3e>�ZZGd4d5�d5e:j[�Z\dWd6d�Z]ej^d7ej_�Z`ej^d8ej_�Zad9d�Zbd:d�Zcd;d �Zdd<d!�Zed=d"�Zfd>d?�Zgd@d$�ZhdAd%�ZidBdC�ZjdDdE�ZkdFdG�ZldHdI�ZmdXdJd&�ZndYdKd#�ZodLdM�ZpGdNdO�dOeQjq�ZrdZdPd'�ZsdQd)�ZtdRd(�ZudSdT�ZvdUdV�ZwdS)[�)�absolute_importNTF)�parse)�request)�InstallationError�HashMismatch)�PyPI)
�splitext�rmtree�format_size�display_path�
backup_dir�ask_path_exists�unpack_file�ARCHIVE_EXTENSIONS�consume�call_subprocess)�auto_decode)�check_path_owner)�
indent_log)�SETUPTOOLS_SHIM)�libc_ver)�DownloadProgressBar�DownloadProgressSpinner)�write_delete_marker_file)�vcs)�requests�six)�BaseAdapter�HTTPAdapter)�AuthBase�
HTTPBasicAuth)�CONTENT_CHUNK_SIZE�Response)�get_netrc_auth)�CaseInsensitiveDict)�urllib3)�CacheControlAdapter)�	FileCache)�	LockError)�
xmlrpc_client�get_file_content�is_url�url_to_path�path_to_url�is_archive_file�unpack_vcs_link�unpack_file_url�
is_vcs_url�is_file_url�unpack_http_url�
unpack_url�parse_content_disposition�sanitize_content_filenamecCsdtjd�tj�dtj�id�}|dddkrBtj�|dd<n�|dddkr�tjjd	krntjd
d�}ntj}djd
d�|D��|dd<nB|dddkr�tj�|dd<n |dddkr�tj�|dd<tjj	d��rJddl
m}tt
dd�tdddg|j����}tt
dd�tddgt����}|�r<||d<|�rJ||d<tjj	d��r|tj�d�r|dtj�dd�|d<tj��r�tj�|jdi�d<tj��r�tj�|jdi�d<tj��r�tj�|d<t�r�tjd
d �d)k�r�tj|d"<d#j|tj|d*d&d'�d(�S)+z6
    Return a string representing the user agent.
    �pip)�name�versionr8)Z	installer�python�implementationr;ZCPythonr9ZPyPy�finalN��.cSsg|]}t|��qS�)�str)�.0�xr?r?�/usr/lib/python3.6/download.py�
<listcomp>Tszuser_agent.<locals>.<listcomp>ZJythonZ
IronPython�linuxr)�distrocSs|dS)N�r?)rBr?r?rC�<lambda>`szuser_agent.<locals>.<lambda>�idcSs|dS)NrGr?)rBr?r?rCrHds�lib�libcrF�darwinZmacOS�system�releaseZcpu��Zopenssl_versionz9{data[installer][name]}/{data[installer][version]} {json}�,�:T)Z
separatorsZ	sort_keys)�data�json)rOrP)rQrR)r7�__version__�platformZpython_versionZpython_implementation�sys�pypy_version_info�releaselevel�join�
startswith�pip._vendorrF�dict�filter�zipZlinux_distributionrZmac_verrM�
setdefaultrN�machine�HAS_TLS�version_info�sslZOPENSSL_VERSION�formatrT�dumps)rSrXrFZdistro_infosrKr?r?rC�
user_agent@sP




rgc@s.eZdZddd�Zdd�Zdd�Zdd	�Zd
S)�MultiDomainBasicAuthTcCs||_i|_dS)N)�	prompting�	passwords)�selfrir?r?rC�__init__�szMultiDomainBasicAuth.__init__cCs�tj|j�}|jjdd�d}tj|dd�|f|dd��|_|jj|d�\}}|dkrn|j|j�\}}|dkr�|dkr�t	|j�}|r�|nd\}}|s�|r�||f|j|<t
|p�d|p�d�|�}|jd|j�|S)	N�@rGrO��response���)NN)NN)
�urllib_parse�urlparse�url�netloc�rsplit�
urlunparserj�get�parse_credentialsr#r Z
register_hook�
handle_401)rk�req�parsedrt�username�passwordZ
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)Ni�z
User for %s: z
Password: rn)�status_coderirqrrrsrZmoves�inputrt�getpassrj�content�rawZrelease_connr rZ
connection�send�history�append)rk�resp�kwargsr{r|r}rzZnew_respr?r?rCry�s


zMultiDomainBasicAuth.handle_401cCs8d|kr4|jdd�d}d|kr,|jdd�S|dfSdS)NrmrGrrR)NN)ru�split)rkrtZuserinfor?r?rCrx�sz&MultiDomainBasicAuth.parse_credentialsN)T)�__name__�
__module__�__qualname__rlr~ryrxr?r?r?rCrh�s
!"rhc@seZdZddd�Zdd�ZdS)�LocalFSAdapterNc
Cs�t|j�}t�}d|_|j|_ytj|�}	Wn.tk
rZ}
zd|_|
|_WYdd}
~
XnPXtj	j
|	jdd�}tj
|�dp~d}t||	j|d��|_t|d�|_|jj|_|S)	N��i�T)Zusegmtrz
text/plain)zContent-TypezContent-Lengthz
Last-Modified�rb)r,rsr"r�os�stat�OSErrorr��emailZutilsZ
formatdate�st_mtime�	mimetypes�
guess_typer$�st_size�headers�open�close)
rkr�stream�timeout�verify�certZproxies�pathnamer�Zstats�excZmodified�content_typer?r?rCr��s$

zLocalFSAdapter.sendcCsdS)Nr?)rkr?r?rCr��szLocalFSAdapter.close)NNNNN)r�r�r�r�r�r?r?r?rCr��s
r�csDeZdZdZ�fdd�Z�fdd�Z�fdd�Z�fdd	�Z�ZS)
�
SafeFileCachezw
    A file based cache which is safe to use even when the target directory may
    not be accessible or writable.
    cs4tt|�j||�t|j�s0tjd|j�d|_dS)Nz�The 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.)�superr�rlr�	directory�logger�warning)rk�argsr�)�	__class__r?rCrl�s
zSafeFileCache.__init__c
s@|jdkrdSytt|�j||�Stttfk
r:YnXdS)N)r�r�r�rwr(r��IOError)rkr�r�)r�r?rCrws
zSafeFileCache.getc
s@|jdkrdSytt|�j||�Stttfk
r:YnXdS)N)r�r�r��setr(r�r�)rkr�r�)r�r?rCr�s
zSafeFileCache.setc
s@|jdkrdSytt|�j||�Stttfk
r:YnXdS)N)r�r�r��deleter(r�r�)rkr�r�)r�r?rCr�)s
zSafeFileCache.delete)	r�r�r��__doc__rlrwr�r��
__classcell__r?r?)r�rCr��s


r�c@seZdZdd�ZdS)�InsecureHTTPAdaptercCsd|_d|_dS)NZ	CERT_NONE)Z	cert_reqsZca_certs)rkZconnrsr�r�r?r?rC�cert_verify9szInsecureHTTPAdapter.cert_verifyN)r�r�r�r�r?r?r?rCr�7sr�cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�
PipSessionNc	s�|jdd�}|jdd�}|jdg�}tt|�j||�t�|jd<t�|_tj	|dgdd�}|rvt
t|d	d
�|d�}n
t|d�}t
|d�}|jd
|�|jd|�|jdt��x|D]}|jdj|�|�q�WdS)N�retriesr�cache�insecure_hostsz
User-Agenti�g�?)ZtotalZstatus_forcelistZbackoff_factorT)Zuse_dir_lock)r��max_retries)r�zhttps://zhttp://zfile://zhttps://{0}/)�popr�r�rlrgr�rhZauthr%ZRetryr&r�rr�Zmountr�re)	rkr�r�r�r�r�Zsecure_adapterZinsecure_adapter�host)r�r?rCrlBs*




zPipSession.__init__cs(|jd|j�tt|�j||f|�|�S)Nr�)r`r�r�r�r)rk�methodrsr�r�)r�r?rCr~szPipSession.request)r�r�r�r�rlrr�r?r?)r�rCr�>s<r�c
CsL|dkrtd��tj|�}|r�|jd�j�}|dkrR|rR|jd�rRtd||f��|dkr�|jdd�d}|jdd	�}t	j
|�}|r�|jd�d|jd
d�d}tj|�}|jd	�r�d	|j
d	�}|}n|j|�}|j�|j|jfSy&t|d��}t|j��}WdQRXWn4tk
�rB}	ztdt|	���WYdd}	~	XnX||fS)
z�Gets 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'rG�file�httpz6Requirements file %s references URL %s, which is localrR�\�/�|r�z$Could not open requirements file: %s)�	TypeError�
_scheme_re�search�group�lowerr[rr��replace�_url_slash_drive_re�matchrqZunquote�lstriprw�raise_for_statusrs�textr�r�readr�r@)
rsZ
comes_from�sessionr��scheme�pathr��fr�r�r?r?rCr*�s>





 z^(http|https|file):z/*([a-z])\|cCs6d|krdS|jdd�dj�}|ddddgtjkS)	z)Returns true if the name looks like a URLrRFrGrr�Zhttpsr�Zftp)r�r�rZall_schemes)r8r�r?r?rCr+�scCsH|jd�std|��tj|�\}}}}}|r6d|}tj||�}|S)z(
    Convert a file: URL to a path.
    zfile:z4You can only turn file: urls into filenames (not %r)z\\)r[�AssertionErrorrqZurlsplit�urllib_requestZurl2pathname)rs�_rtr�r?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:)r�r��normpath�abspathrqZurljoinr�Zpathname2url)r�rsr?r?rCr-�scCs t|�dj�}|tkrdSdS)z9Return True if `name` is a considered as an archive file.rGTF)rr�r)r8�extr?r?rCr.�scCst|�}|j|�dS)N)�_get_used_vcs_backend�unpack)�link�location�vcs_backendr?r?rCr/�scCs.x(tjD]}|j|jkr||j�}|SqWdS)N)rZbackendsr�Zschemesrs)r�Zbackendr�r?r?rCr��s
r�cCstt|��S)N)�boolr�)r�r?r?rCr1�scCs|jj�jd�S)Nzfile:)rsr�r[)r�r?r?rCr2�scCst|j�}tjj|�S)z�Return 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_fragmentr�r��isdir)r��	link_pathr?r?rC�
is_dir_url�s
r�cOs|S)Nr?)�iterabler�r�r?r?rC�_progress_indicator�sr�c

sLyt�jd�}Wntttfk
r0d}YnXt�dd�}tj�tj	krRd}n&|r\d}n|dkrjd}n|std}nd}|j
}�fdd	�}�fd
d�}	t}
|jt
jkr�|}n|j}|r�|r�tjd|t|��t|d
�j}
ntjd|�t�j}
n |�rtjd|�ntjd|�tjd|�|	|
|t�t��}|�r@|j|�nt|�dS)Nzcontent-lengthrZ
from_cacheF�(i�Tc3s\y$x�jj|dd�D]
}|VqWWn2tk
rVx�jj|�}|sHP|Vq6WYnXdS)NF)Zdecode_content)r�r��AttributeErrorr�)Z
chunk_size�chunk)r�r?rC�	resp_readsz _download_url.<locals>.resp_readc3s"x|D]}�j|�|VqWdS)N)�write)Zchunksr�)�content_filer?rC�written_chunks;s

z%_download_url.<locals>.written_chunkszDownloading %s (%s))�maxzDownloading %szUsing cached %szDownloading from URL %si@�)�intr��
ValueError�KeyErrorr��getattrr�ZgetEffectiveLevel�logging�INFO�show_urlr�rtrr��infor
r�iterr�debugr!Zcheck_against_chunksr)
r�r�r��hashesZtotal_lengthZcached_respZ
show_progressr�r�r�Zprogress_indicatorrsZdownloaded_chunksr?)r�r�rC�
_download_urlsL
%
r�cCs�d}tjj||j�}tjj|�r�tdt|�d�}|dkr@d}nj|dkrdtjdt|��tj	|�nF|dkr�t
|�}tjd	t|�t|��tj||�n|dkr�t
jd
�|r�tj||�tjdt|��dS)NTz8The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)abort�i�w�b�aFzDeleting %szBacking up %s to %srGzSaved %s)r�r�r�r�rp)r�r�rZ�filename�existsr
rr�r��remover�shutilZmoverW�exit�copyr�)r�r�r�r�Zdownload_locationroZ	dest_filer?r?rC�
_copy_fileas.

r�c	Cs�|dkrtd��tjdd�}d}|r0t|||�}|rH|}tj|�d}nt||||�\}}t||||�|r~|r~t|||�|s�t	j
|�t|�dS)Nz@unpack_http_url() missing 1 required keyword argument: 'session'z-unpackzpip-r)r��tempfileZmkdtemp�_check_download_dirr�r��_download_http_urlrr�r��unlinkr	)	r�r��download_dirr�r��temp_dir�already_downloaded_path�	from_pathr�r?r?rCr3|s,


cCs�t|j�}t|�rHtjj|�r&t|�tj||dd�|rDt	j
d�dS|rV|j|�d}|rjt|||�}|rt|}n|}t
j|�d}t||||�|r�|r�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.
    T)Zsymlinksz*Link is a directory, ignoring download_dirNr)r,r�r�r�r�r�r	r�Zcopytreer�r��check_against_pathr�r�r�rr�)r�r�rr�r�rrr�r?r?rCr0�s,



c
Cs�tjj|�rt|�d}tjg}|jd�|jt|�|jd�|d|g7}tj	d|�t
��t||dd�WdQRXtjj|tj
|�d	�}tj	d
||�t||ddd�dS)z�Copy 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-c�sdistz
--dist-dirzRunning setup.py sdist for %sF)�cwdZshow_stdoutNrzUnpacking sdist %s into %s)r�r�)r�r�r�r	rW�
executabler�rr�r�rrrZ�listdirr)r�r�Zsetup_pyZ
sdist_argsrr?r?rC�_copy_dist_from_dir�s

rc@s$eZdZdZddd�Zd	dd�ZdS)
�PipXmlrpcTransportzRProvide a `xmlrpclib.Transport` implementation via a `PipSession`
    object.
    FcCs*tjj||�tj|�}|j|_||_dS)N)r)�	Transportrlrqrrr��_scheme�_session)rkZ	index_urlr�Zuse_datetimeZindex_partsr?r?rCrl�s
zPipXmlrpcTransport.__init__c
Cs�|j||dddf}tj|�}y6ddi}|jj|||dd�}|j�||_|j|j�St	j
k
r�}	ztjd|	j
j|��WYdd}	~	XnXdS)NzContent-Typeztext/xmlT)rSr�r�zHTTP error %s while getting %s)rrqrvrZpostr��verboseZparse_responser�r�	HTTPErrorr��criticalror)
rkr�ZhandlerZrequest_bodyr�partsrsr�ror�r?r?rCrs


zPipXmlrpcTransport.requestN)F)F)r�r�r�r�rlrr?r?r?rCr�s
rcCs^t|�rt||�n:t|�r.t||||d�n |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.
    )r�N)r1r/r2r0r�r3r)r�r�rZ
only_downloadr�r�r?r?rCr4scCstjj|�S)zJ
    Sanitize the "filename" value from a Content-Disposition header.
    )r�r��basename)r�r?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_typeZparamsr�r?r?rCr5Ds

c
Cs*|jjdd�d}y |j|ddidd�}|j�Wn8tjk
rj}ztjd|jj	|��WYd	d	}~XnX|j
jd
d�}|j}|j
jd�}	|	r�t|	|�}t
|�d}
|
s�tj|�}
|
r�||
7}|
r�|j|jkr�tjj
|j�d}
|
r�||
7}tjj||�}t|d
��}t||||�Wd	QRX||fS)z6Download link url into temp_dir using provided session�#rGrzAccept-EncodingZidentityT)r�r�zHTTP error %s while getting %sNzcontent-typernzcontent-disposition�wb)rsr�rwr�rrr�rrorr�r�r5rr�Zguess_extensionr�r�rZr�r�)
r�r�rr�Z
target_urlr�r�r�r�rr�Z	file_pathr�r?r?rCrSs:

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)r�r�rZr�r�r�r�rrr�r)r�rr�Z
download_pathr?r?rCr��s
r�)NN)NNN)NN)NFNN)xZ
__future__rrZemail.utilsr�r�rTr�r�r�rV�rer�rWr�rdrb�ImportErrorZpip._vendor.six.moves.urllibrrqrr�r7Zpip.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	getLoggerr�r�rgrhr�r�r�ZSessionr�r*�compile�Ir�r�r+r,r-r.r/r�r1r2r�r�r�r�r3r0rr
rr4r6r5rr�r?r?r?rC�<module>s�
0
BR!BH
)
`
&
0$
'8