AlkantarClanX12

Your IP : 3.144.255.116


Current Path : /opt/alt/python34/lib/python3.4/site-packages/pip/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib/python3.4/site-packages/pip/__pycache__/util.cpython-34.pyc

�
�Re$b�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
mZddlmZmZmZmZmZmZddlmZmZmZddlmZddlmZddlmZdd	d
ddd
ddddddddddddddddddd gZ d!d�Z!d"d#d�Z"d$d%�Z#d&d	�Z$d'd(d
�Z%ddd)d�Z&dd*d+�Z'd,d-�Z(d.d�Z)Gd/d0�d0e*�Z+e+�Z,[+ej-d1ej.�Z/d2d�Z0d3d�Z1d4d�Z2d5d�Z3d6d�Z4d7d�Z5d8d�Z6d9d�Z7d:d�Z8d;d�Z9d<d�Z:d=d>�Z;d?d@�Z<dAdB�Z=dCdD�Z>dEdF�Z?dGd_dGd"dLdM�Z@dNdO�ZAdPdQ�ZBdRd�ZCdSdT�ZDdGdUd�ZEdVd�ZFdWd�ZGdXd�ZHdYd�ZIdGdddGejJdddZd �ZKd[d\�ZLGd]d^�d^e*�ZMdS)`�N)�InstallationError�
BadCommand�PipError)�WindowsError�string_types�	raw_input�console_to_str�	user_site�PermissionError)�
site_packages�running_under_virtualenv�virtualenv_no_global)�logger)�
pkg_resources)�version�rmtree�display_path�
backup_dir�find_command�ask�Inf�normalize_name�splitext�format_size�is_installable_dir�is_svn_page�
file_contents�split_leading_dir�has_leading_dir�make_path_relative�normalize_path�renames�get_terminal_size�get_prog�
unzip_file�
untar_file�create_download_cache_folder�cache_download�unpack_file�call_subprocessc
CsPy.tjjtjd�dkr-dtjSWntttfk
rKYnXdS)Nr�__main__.py�-cz	%s -m pip�pip)r*r+)	�os�path�basename�sys�argv�
executable�AttributeError�	TypeError�
IndexError�r6r6�#/tmp/pip-ztkk0jow-build/pip/util.pyr#!sFcCstj|d|dt�dS)N�
ignore_errors�onerror)�shutilr�rmtree_errorhandler)�dirr8r6r6r7r*scCs�|dd�\}}|tkr5|jddkpp|tkrT|jddkpp|tkop|jddksy�ntj|�jtj@tjkr��ntj|tj	�||�dS)z�On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems.N�r��
�)
r�args�OSErrorr
r-�stat�st_mode�S_IREAD�chmod�S_IWRITE)�funcr.�exc_info�exctype�valuer6r6r7r;/s"r;cCsdtjjtjj|��}|jtj�tjj�r`d|ttj��d�}n|S)zTGives the display value for a given path, making it relative to cwd
    if possible.�.N)r-r.�normcase�abspath�
startswith�getcwd�sep�len)r.r6r6r7rBs#z.bakcCsKd}|}x4tjj||�rB|d7}|t|�}qW||S)z\Figure out the name of a directory to back up the given dir to
    (adding .bak, .bak2, etc)�)r-r.�exists�str)r<�ext�n�	extensionr6r6r7rKs
cCs7|dkr0tjjdd�jtj�}nt|t�rK|g}n|dkrct�}ndd�|j�jtj�D�}tj	j
|�dj�|kr�dg}nxj|D]b}tj	j||�}x.|D]&}||}tj	j|�r�|Sq�Wtj	j|�r�|Sq�Wt
d|��dS)z<Searches the PATH for the given command and returns its pathN�PATH�cSs"g|]}t|�r|�qSr6)rR)�.0rVr6r6r7�
<listcomp>_s	z find_command.<locals>.<listcomp>rSzCannot find command %r)r-�environ�get�split�pathsep�
isinstancer�get_pathext�lowerr.r�join�isfiler)�cmd�paths�pathextr.�cmd_pathrV�cmd_path_extr6r6r7rVs$$%"


cCsF|dkr-tjjddddg�}ntjjd|�}|S)z9Returns the path extensions from environment or a defaultNz.COMz.EXEz.BATz.CMD�PATHEXT)r-r`rdr]r^)�default_pathextrhr6r6r7rbqs!rbcCsCx3tjjdd�j�D]}||kr|SqWt||�S)N�PIP_EXISTS_ACTIONrZ)r-r]r^r_r)�message�options�actionr6r6r7�ask_path_existsys"rqcCs~xwtjjd�r(td|��nt|�}|j�j�}||krrtd|dj|�f�q|SqWdS)z@Ask the message interactively, with the given possible responses�PIP_NO_INPUTz7No input was expected ($PIP_NO_INPUT set); question: %sz<Your response (%r) was not one of the expected responses: %sz, N)	r-r]r^�	Exceptionr�striprc�printrd)rnro�responser6r6r7r�sc@sjeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�_InfzI am bigger than everything!cCs||krdSdSdS)NTFr6)�self�otherr6r6r7�__eq__�sz_Inf.__eq__cCs|j|�S)N)rz)rxryr6r6r7�__ne__�sz_Inf.__ne__cCsdS)NFr6)rxryr6r6r7�__lt__�sz_Inf.__lt__cCsdS)NFr6)rxryr6r6r7�__le__�sz_Inf.__le__cCsdS)NTr6)rxryr6r6r7�__gt__�sz_Inf.__gt__cCsdS)NTr6)rxryr6r6r7�__ge__�sz_Inf.__ge__cCsdS)Nrr6)rxr6r6r7�__repr__�sz
_Inf.__repr__N)�__name__�
__module__�__qualname__�__doc__rzr{r|r}r~rr�r6r6r6r7rw�srwz[^a-z]cCstjd|j��S)N�-)�
_normalize_re�subrc)�namer6r6r7r�scCsX|dkrd|ddS|d	kr4d|dS|dkrLd|dSd|SdS)
Ni�z%.1fMBg@�@�
z%ikBz%.1fkBz%ibytesi@Bi'r6)�bytesr6r6r7r�scCsEtjj|�sdStjj|d�}tjj|�rAdSdS)z@Return True if `path` is a directory containing a setup.py file.Fzsetup.pyT)r-r.�isdirrdre)r.�setup_pyr6r6r7r�scCs(tjd|�o'tjd|tj�S)zJReturns true if the page appears to be the index page of an svn repositoryz<title>[^<]*Revision \d+:z#Powered by (?:<a[^>]*?>)?Subversion)�re�search�I)�htmlr6r6r7r�sc
Cs8t|d�}z|j�jd�SWd|j�XdS)N�rbzutf-8)�open�read�decode�close)�filename�fpr6r6r7r�scCs�t|�}|jd�jd�}d|krvd|krZ|jd�|jd�ksfd|krv|jdd�Sd|kr�|jdd�S|dfSdS)N�/�\rSrZ)rU�lstrip�findr_)r.r6r6r7r�s6cCs\d}xO|D]G}t|�\}}|s/dS|dkrD|}q
||kr
dSq
WdS)zyReturns true if all the paths have the same leading path name
    (i.e., everything is in one subdirectory in an archive)NFT)r)rg�
common_prefixr.�prefix�restr6r6r7r�s
	cCs7tjj|�}tjj|�}tjjtjj|��}tjjtjj|��}|jtjj�jtjj�}|jtjj�jtjj�}x>|r�|r�|d|dkr�|j	d�|j	d�q�Wdgt
|�||g}|dgkr$dtjjStjjj|�S)a
    Make a filename relative, where the filename path, and it is
    relative to rel_to

        >>> make_relative_path('/usr/share/something/a-file.pth',
        ...                    '/usr/share/another-place/src/Directory')
        '../../../something/a-file.pth'
        >>> make_relative_path('/usr/share/something/a-file.pth',
        ...                    '/home/user/src/Directory')
        '../../../usr/share/something/a-file.pth'
        >>> make_relative_path('/usr/share/a-file.pth', '/usr/share/')
        'a-file.pth'
    rz..rZrL)r-r.r/�dirname�normpathrNrtrQr_�poprRrd)r.�rel_to�
path_filename�
path_parts�rel_to_parts�
full_partsr6r6r7r�s$$#
cCs(tjjtjjtjj|���S)zN
    Convert a path to its canonical, case-normalized, absolute version.

    )r-r.rM�realpath�
expanduser)r.r6r6r7r scCs[tj|�\}}|j�jd�rQ|dd�|}|dd�}n||fS)z,Like os.path.splitext, but take off .tar tooz.tar�N���r�)�	posixpathrrc�endswith)r.�baserVr6r6r7rs
cCs�tjj|�\}}|rG|rGtjj|�rGtj|�ntj||�tjj|�\}}|r�|r�ytj|�Wq�tk
r�Yq�XndS)z7Like os.renames(), but handles renaming across devices.N)	r-r.r_rT�makedirsr:�move�
removedirsrB)�old�new�head�tailr6r6r7r!!s
cCs)t�s
dSt|�jttj��S)z�
    Return True if path is within sys.prefix, if we're running in a virtualenv.

    If we're not in a virtualenv, all paths are considered "local."

    T)rr rOr0r�)r.r6r6r7�is_local2s	r�cCstt|��S)z�
    Return True if given Distribution object is installed locally
    (i.e. within current virtualenv).

    Always True if we're not in a virtualenv.

    )r��
dist_location)�distr6r6r7�
dist_is_local>sr�cCs-tr%tt|��jtt��SdSdS)zF
    Return True if given Distribution is installed in user site.
    FN)r	r r�rO)r�r6r6r7�dist_in_usersiteIsr�cCstt|��jtt��S)za
    Return True if given Distribution is installed in distutils.sysconfig.get_python_lib().
    )r r�rOr)r�r6r6r7�dist_in_site_packagesRsr�cCs)ddlm}|j|g�}|jS)z$Is distribution an editable install?r)�FrozenRequirement)r,r��	from_dist�editable)r�r��reqr6r6r7�dist_is_editableYsr�T�
setuptoolsr,�python�
distributecs�|rt�ndd��|r0dd��ndd��|rQdd��ndd������fdd�tjD�S)	a�
    Return a list of installed Distribution objects.

    If ``local_only`` is True (default), only return installations
    local to the current virtualenv, if in a virtualenv.

    ``skip`` argument is an iterable of lower-case project names to
    ignore; defaults to ('setuptools', 'pip', 'python'). [FIXME also
    skip virtualenv?]

    If ``editables`` is False, don't report editables.

    If ``editables_only`` is True , only report editables.

    cSsdS)NTr6)�dr6r6r7�<lambda>vsz-get_installed_distributions.<locals>.<lambda>cSsdS)NTr6)r�r6r6r7r�yscSst|�S)N)r�)r�r6r6r7r�{scSs
t|�S)N)r�)r�r6r6r7r�~scSsdS)NTr6)r�r6r6r7r��scsIg|]?}�|�r|j�kr�|�r�|�r|�qSr6)�key)r[r�)�
editable_test�editables_only_test�
local_test�skipr6r7r\�s
	z/get_installed_distributions.<locals>.<listcomp>)r�r�working_set)�
local_onlyr��include_editables�editables_onlyr6)r�r�r�r�r7�get_installed_distributions`s	r�cCs�g}t�rNt�r(|jt�qq|jt�trq|jt�qqn#trd|jt�n|jt�x@|D]8}tjj||j�d}tjj	|�rx|SqxWdS)a
    Return the path for the .egg-link file if it exists, otherwise, None.

    There's 3 scenarios:
    1) not in a virtualenv
       try to find in site.USER_SITE, then site_packages
    2) in a no-global virtualenv
       try to find in site_packages
    3) in a yes-global virtualenv
       try to find in site_packages, then site.USER_SITE  (don't look in global location)

    For #1 and #3, there could be odd cases, where there's an egg-link in 2 locations.
    This method will just return the first one found.
    z	.egg-linkN)
rr
�appendrr	r-r.rd�project_namere)r��sites�site�egglinkr6r6r7�
egg_link_path�s		


r�cCst|�}|r|S|jS)z�
    Get the site-packages location of this distribution. Generally
    this is dist.location, except in the case of develop-installed
    packages, where dist.location is the source code location, and we
    want to know where the egg-link file is.

    )r��location)r��egg_linkr6r6r7r��sr�c
Cs�dd�}|d�p-|d�p-|d�}|s|y8tjtj�tj�}||�}tj|�Wq|Yq|Xn|s�tjjdd�tjjdd	�f}nt|d�t|d�fS)
zlReturns a tuple (x, y) representing the width(x) and the height(x)
    in characters of the terminal window.cSsyLddl}ddl}ddl}|jd|j||jd��}WndSYnX|dkrkdS|dkr{dS|S)Nr�hh�1234)rr)rr)�fcntl�termios�struct�unpack�ioctl�
TIOCGWINSZ)�fdr�r�r��crr6r6r7�ioctl_GWINSZ�s	z'get_terminal_size.<locals>.ioctl_GWINSZrrSr=�LINES��COLUMNS�P)r-r��ctermid�O_RDONLYr�r]r^�int)r�r�r�r6r6r7r"�s$-cCs tjd�}tj|�|S)zBGet the current umask which involves having to set it temporarily.r)r-�umask)�maskr6r6r7�
current_umask�s
r�c
Cs�tjj|�s"tj|�nt|d�}z}tj|�}t|j��oX|}xO|j	�D]A}|j
}|j|�}|}	|r�t|�d}	ntjj
||	�}	tjj|	�}
tjj|
�s�tj|
�n|	jd�s|	jd�r1tjj|	�s�tj|	�q�qht|	d�}z|j|�Wd|j�|jd?}|r�tj|�r�|d@r�tj|	d	t�dB�nXqhWWd|j�XdS)
a�
    Unzip the file (with path `filename`) to the destination `location`.  All
    files are written based on system defaults and umask (i.e. permissions are
    not preserved), except that regular file members with any execute
    permissions (user, group, or world) have "chmod +x" applied after being
    written. Note that for windows, any execute changes using os.chmod are
    no-ops per the python docs.
    r�rSr�r��wbN��Ii�)r-r.rTr�r��zipfile�ZipFiler�namelist�infolistr�r�rrdr�r��writer��
external_attrrC�S_ISREGrFr�)
r�r��flatten�zipfp�zip�leading�infor��data�fnr<r��moder6r6r7r$�s6		

'cCs�tjj|�s"tj|�n|j�jd�sL|j�jd�rUd}nh|j�jd�s|j�jd�r�d}n5|j�jd�r�d}ntjd	|�d
}tj	||�}zt
dd�|j�D��}x�|j�D]�}|j}|d
krq�n|r8t
|�d}ntjj||�}|j�r~tjj|�s�tj|�q�q�|j�r�y|j||�Wq�tj�d}tjd||j|f�w�Yq�Xq�y|j|�}	WnHttfk
r9tj�d}tjd||j|f�w�YnXtjjtjj|��sttjtjj|��nt	|d�}
ztj|	|
�Wd|
j�X|	j�|jd@r�tj|dt�dB�q�q�WWd|j�XdS)a�
    Untar the file (with path `filename`) to the destination `location`.
    All files are written based on system defaults and umask (i.e. permissions
    are not preserved), except that regular file members with any execute
    permissions (user, group, or world) have "chmod +x" applied after being
    written.  Note that for windows, any execute changes using os.chmod are
    no-ops per the python docs.
    z.gzz.tgzzr:gzz.bz2z.tbzzr:bz2z.tar�rz-Cannot determine compression type for file %szr:*cSs(g|]}|jdkr|j�qS)�pax_global_header)r�)r[�memberr6r6r7r\$s	zuntar_file.<locals>.<listcomp>r�rSz/In the tar file %s the member %s is invalid: %sr�Nr�i�)r-r.rTr�rcr�r�warn�tarfiler�r�
getmembersr�rrdr��issym�_extract_memberr0rI�extractfile�KeyErrorr3r�r:�copyfileobjr�r�rFr�)r�r�r��tarr�rr�r.�er��destfpr6r6r7r%sf	*	*			

&cCs@tjd8_tjd|�tjd7_tj|�dS)Nr=z&Creating supposed download cache at %s)r�indent�notifyr-r�)�folderr6r6r7r&XscCsUtjdt|��tj||�t|dd�}|j|�|j�dS)NzStoring download in cache at %sz
.content-type�w)rr
rr:�copyfiler�r�r�)�target_file�
temp_location�content_typer�r6r6r7r'_s

cCsCtjj|�}|dksZ|jd�sZ|jd�sZ|jd�sZtj|�rzt||d|jd��n�|dks�tj|�s�t	|�dj
�dkr�t||�n~|r|jd
�rt
t|��rddlm}|d|j�j|�n*tjd|||f�td|��dS)Nzapplication/zipz.zip�	.pybundle�.whlr�zapplication/x-gziprS�.tar�.tar.gz�.tar.bz2�.tgz�.tbzz	text/htmlr)�
Subversionzsvn+zZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz%Cannot determine archive format of %s)rr)rrrrr)r-r.r�r�r��
is_zipfiler$r�
is_tarfilerrcr%rOrr�pip.vcs.subversionr�urlr�r�fatalr)r�r�r�linkrr6r6r7r(gs$ 	cCs�|dkr�g}xd|D]\}	d|	ksOd|	ksOd|	ksOd|	krhd|	jdd�}	n|j|	�qWdj|�}n|r�d}
n	tj}
tj|d|�tjj	�}|r�|j
|�ny4tj|dtjd	dd
|
d|d|�}Wn<t
k
rNtj�d
}
tjd|
|f��YnXg}|
dk	r|j}
x�t|
j��}|s�Pn|j�}|j|d�|r||�}t|t�r�|\}}ntj||�tj|�stj�qqmtj|�qmWn!|j�\}}|p4dg}|j�|jr�|r�|r�tjd|�tjdj|�d�ntd||j|f��q�tjd||j|f�n|
dk	r�dj|�SdS)N� �
�"�'z"%s"z\"zRunning command %s�stderr�stdin�stdout�cwd�envrSz#Error %s while executing command %srZz Complete output from command %s:z)
----------------------------------------z*Command %s failed with error code %s in %sz"Command %s had error code %s in %s) �replacer�rd�
subprocess�PIPEr�logr-r]�copy�update�Popen�STDOUTrsr0rIr r(r�readline�rstripra�tuple�stdout_level_matches�
show_progressr��communicate�wait�
returncoder
rr)rf�show_stdout�
filter_stdoutr)�raise_on_returncode�
command_level�command_desc�
extra_environ�	cmd_parts�partr(r*�procr
�
all_output�line�level�returned_stdout�returned_stderrr6r6r7r)�sp
0		
	
	cCsEtj|�}|dkrdStj|�}tdd�|D��S)z�
    Attempt to determine if this is a pre-release using PEP386/PEP426 rules.

    Will return True if it is a pre-release and False if not. Versions are
    assumed to be a pre-release if they cannot be parsed.
    NTcSs)g|]}tdd�|D���qS)c	Ss1g|]'}|tdddddg�k�qS)�a�b�c�rc�dev)�set)r[�yr6r6r7r\�s	z,is_prerelease.<locals>.<listcomp>.<listcomp>)�any)r[�xr6r6r7r\�s	z!is_prerelease.<locals>.<listcomp>)r�_suggest_normalized_version�_normalized_keyrP)�vers�
normalized�parsedr6r6r7�
is_prerelease�s
rWc@sReZdZdddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�BuildDirectoryNcCsm|dkr!|dkr!d}n|dkrWtjdd�}|dkrWd}qWn||_||_dS)NTr�z
pip-build-)�tempfile�mkdtempr��delete)rxr�r[r6r6r7�__init__�s		zBuildDirectory.__init__cCsdj|jj|j�S)Nz	<{} {!r}>)�format�	__class__r�r�)rxr6r6r7r��szBuildDirectory.__repr__cCs|jS)N)r�)rxr6r6r7�	__enter__�szBuildDirectory.__enter__cCs|j�dS)N)�cleanup)rx�excrK�tbr6r6r7�__exit__�szBuildDirectory.__exit__cCs|jrt|j�ndS)N)r[rr�)rxr6r6r7r`�s	zBuildDirectory.cleanup)r�r�r�r\r�r_rcr`r6r6r6r7rX�s
rX)z
setuptoolszpipzpythonz
distribute)Nr0r:r-rCr�r�r�rr,�textwraprY�pip.exceptionsrrrZpip.backwardcompatrrrrr	r
�
pip.locationsrrr
�pip.logr�pip._vendorr�pip._vendor.distlibr�__all__r#rr;rrrrbrqr�objectrwr�compiler�r�rrrrrrrrr rr!r�r�r�r�r�r�r�r�r"r�r$r%r&r'r(�DEBUGr)rWrXr6r6r6r7�<module>s�.							
		'"-L	?