ok

Mini Shell

Direktori : /proc/thread-self/root/usr/lib/python2.7/site-packages/pip/utils/
Upload File :
Current File : //proc/thread-self/root/usr/lib/python2.7/site-packages/pip/utils/__init__.pyc

�
��abc@@s�ddlmZddlmZddlZddlZddlZddlZddlZ	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZddlmZmZmZddlmZmZmZmZmZddlm Z ddl!m"Z"dd	l#m$Z$dd
l%m&Z&e$ruddlm'Z(nddlm(Z(d
ddddddddddddddddddd d!d"d#d$gZ)e	j*e+�Z,dfZ-dgZ.dhZ/diZ0e/e-e0e.Z1e/e0Z2yddl3Z3e2e-7Z2Wne4k
rPe,j5d1�nXyddl6Z6e2e.7Z2Wne4k
r�e,j5d2�nXd3�Z7d4�Z8d5�Z9e&d6d7d8d9�e:d:��Z;d;�Z<d<�Z=d=d>�Z>d?�Z?d@�Z@dA�ZAdB�ZBdC�ZCdD�ZDejEdE�ZFdF�ZGdG�ZHeIdH�ZJdI�ZKdJ�ZLdK�ZMdL�ZNdM�ZOdN�ZPdO�ZQeIeeIe:e:dP�ZRdQ�ZSdR�ZTdS�ZUdT�ZVeIdU�ZWdV�ZXdW�ZYeIddXddddY�Z[dZ�Z\d[�Z]d\e^fd]��YZ_d^e(fd_��YZ`ejad`��Zbda�Zcdbe^fdc��YZdddd�Zede�ZfdS(ji(tabsolute_import(tdequeN(tInstallationError(tconsole_to_strt
expandusertstdlib_pkgs(t
site_packagest	user_sitetrunning_under_virtualenvtvirtualenv_no_globaltwrite_delete_marker_file(t
pkg_resources(tinput(tPY2(tretry(tBytesIO(tStringIOtrmtreetdisplay_patht
backup_dirtasktsplitexttformat_sizetis_installable_dirtis_svn_paget
file_contentstsplit_leading_dirthas_leading_dirtnormalize_pathtrenamestget_terminal_sizetget_progt
unzip_filet
untar_filetunpack_filetcall_subprocesstcaptured_stdoutt
ensure_dirtARCHIVE_EXTENSIONStSUPPORTED_EXTENSIONStget_installed_versions.tar.bz2s.tbzs.tar.xzs.txzs.tlzs.tar.lzs	.tar.lzmas.zips.whls.tar.gzs.tgzs.tarsbz2 module is not availableslzma module is not availablecO@s5yt|�SWn tk
r0|||��nXdS(N(t
__import__tImportError(tpkg_or_module_stringt
ExceptionTypetargstkwargs((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytimport_or_raiseIs
cC@sCytj|�Wn+tk
r>}|jtjkr?�q?nXdS(s os.path.makedirs without EEXIST.N(tostmakedirstOSErrorterrnotEEXIST(tpathte((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR%Ps
cC@sOy.tjjtjd�dkr-dtjSWntttfk
rJnXdS(Nis__main__.pys-cs	%s -m piptpip(s__main__.pys-c(	R0R5tbasenametsystargvt
executabletAttributeErrort	TypeErrort
IndexError(((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyRYststop_max_delayi�t
wait_fixedi�cC@stj|d|dt�dS(Nt
ignore_errorstonerror(tshutilRtrmtree_errorhandler(tdirRA((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyRcscC@sAtj|�jtj@r:tj|tj�||�dS�dS(s�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(R0tstattst_modetS_IREADtchmodtS_IWRITE(tfuncR5texc_info((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyRDis

cC@s�tjjtjj|��}tjddkrd|jtj�d�}|jtj	�d�}n|j
tj�tjj�r�d|t
tj��}n|S(sTGives the display value for a given path, making it relative to cwd
    if possible.iitreplacet.(R0R5tnormcasetabspathR9tversion_infotdecodetgetfilesystemencodingtencodetgetdefaultencodingt
startswithtgetcwdtseptlen(R5((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyRxss.bakcC@sKd}|}x4tjj||�rB|d7}|t|�}qW||S(s\Figure out the name of a directory to back up the given dir to
    (adding .bak, .bak2, etc)i(R0R5texistststr(REtexttnt	extension((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�s
cC@sCx3tjjdd�j�D]}||kr|SqWt||�S(NtPIP_EXISTS_ACTIONt(R0tenvirontgettsplitR(tmessagetoptionstaction((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytask_path_exists�s"cC@syxrtjjd�r(td|��nt|�}|j�j�}||krmd|dj|�fGHq|SqWdS(s@Ask the message interactively, with the given possible responsestPIP_NO_INPUTs7No input was expected ($PIP_NO_INPUT set); question: %ss<Your response (%r) was not one of the expected responses: %ss, N(R0RaRbt	ExceptionRtstriptlowertjoin(RdRetresponse((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�s
cC@sX|dkrd|ddS|d	kr4d|dS|dkrLd|dSd|SdS(
Ni�s%.1fMBg@�@i
s%ikBs%.1fkBs%ibytesi@Bi'((tbytes((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�scC@sEtjj|�stStjj|d�}tjj|�rAtStS(s@Return True if `path` is a directory containing a setup.py file.ssetup.py(R0R5tisdirtFalseRltisfiletTrue(R5tsetup_py((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�scC@s(tjd|�o'tjd|tj�S(sT
    Returns true if the page appears to be the index page of an svn repository
    s<title>[^<]*Revision \d+:s#Powered by (?:<a[^>]*?>)?Subversion(tretsearchtI(thtml((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�scC@s/t|d��}|j�jd�SWdQXdS(Ntrbsutf-8(topentreadRR(tfilenametfp((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�scc@s/x(tr*|j|�}|s"Pn|VqWdS(s7Yield pieces of data from a file-like object until EOF.N(RrRz(tfiletsizetchunk((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytread_chunks�s
	cC@s�|jd�jd�}d|krjd|krN|jd�|jd�ksZd|krj|jdd�Sd|kr�|jdd�S|dfSdS(Nt/s\iR`(tlstriptfindRc(R5((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�s6cC@s\d}xO|D]G}t|�\}}|s/tS|dkrD|}q
||kr
tSq
WtS(syReturns true if all the paths have the same leading path name
    (i.e., everything is in one subdirectory in an archive)N(tNoneRRpRr(tpathst
common_prefixR5tprefixtrest((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�s
	cC@sIt|�}|r'tjj|�}ntjj|�}tjj|�S(sN
    Convert a path to its canonical, case-normalized, absolute version.

    (RR0R5trealpathRPRO(R5tresolve_symlinks((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�s
cC@sOtj|�\}}|j�jd�rE|d|}|d }n||fS(s,Like os.path.splitext, but take off .tar toos.tari����(t	posixpathRRktendswith(R5tbaseR\((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�s

cC@s�tjj|�\}}|rG|rGtjj|�rGtj|�ntj||�tjj|�\}}|r�|r�ytj|�Wq�tk
r�q�XndS(s7Like os.renames(), but handles renaming across devices.N(	R0R5RcRZR1RCtmovet
removedirsR2(toldtnewtheadttail((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyRs
cC@s)t�s
tSt|�jttj��S(s�
    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."

    (RRrRRVR9R�(R5((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytis_locals	cC@stt|��S(s�
    Return True if given Distribution object is installed locally
    (i.e. within current virtualenv).

    Always True if we're not in a virtualenv.

    (R�t
dist_location(tdist((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt
dist_is_local!scC@s%tt|��}|jtt��S(sF
    Return True if given Distribution is installed in user site.
    (RR�RVR(R�t	norm_path((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytdist_in_usersite,scC@stt|��jtt��S(se
    Return True if given Distribution is installed in
    distutils.sysconfig.get_python_lib().
    (RR�RVR(R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytdist_in_site_packages4scC@sJxCtjD]8}tjj||jd�}tjj|�r
tSq
WtS(s$Is distribution an editable install?s	.egg-link(R9R5R0Rltproject_nameRqRrRp(R�t	path_itemtegg_link((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytdist_is_editable>s
c
C@s�|rt}n	d�}|r*d�}n	d�}|rEd�}n	d�}|r]t}n	d�}gtjD]K}	||	�rp|	j|krp||	�rp||	�rp||	�rp|	^qpS(s�
    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 stdlib_pkgs

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

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

    If ``user_only`` is True , only report installations in the user
    site directory.

    cS@stS(N(Rr(td((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt
local_test`scS@stS(N(Rr(R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt
editable_testdscS@st|�S(N(R�(R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�gscS@s
t|�S(N(R�(R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyteditables_only_testkscS@stS(N(Rr(R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�nscS@stS(N(Rr(R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt	user_testts(R�R�Rtworking_settkey(
t
local_onlytskiptinclude_editablesteditables_onlyt	user_onlyR�R�R�R�R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytget_installed_distributionsGs$						cC@s�g}t�rNt�r(|jt�qq|jt�trq|jt�qqn#trd|jt�n|jt�x@|D]8}tjj||j�d}tjj	|�rx|SqxWdS(s
    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.
    s	.egg-linkN(
RR	tappendRRR0R5RlR�Rq(R�tsitestsitetegglink((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt
egg_link_path�s		


cC@st|�}|r|S|jS(s�
    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�tlocation(R�R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR��scC@s�d�}|d�p*|d�p*|d�}|sxy8tjtj�tj�}||�}tj|�WqxqxXn|s�tjjdd�tjjdd�f}nt|d�t|d�fS(	slReturns a tuple (x, y) representing the width(x) and the height(x)
    in characters of the terminal window.cS@skyLddl}ddl}ddl}|jd|j||jd��}WndSX|dkrgdS|S(Nithht1234(ii(tfcntlttermioststructtunpacktioctlt
TIOCGWINSZR�(tfdR�R�R�tcr((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytioctl_GWINSZ�siiitLINESitCOLUMNSiP(R0RytctermidtO_RDONLYtcloseRaRbtint(R�R�R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR�s	$-cC@s tjd�}tj|�|S(sBGet the current umask which involves having to set it temporarily.i(R0tumask(tmask((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt
current_umask�s
c
C@s~t|�t|d�}zStj|dt�}t|j��oF|}x|j�D]}|j}|j	|�}|}	|r�t
|�d}	ntjj
||	�}	tjj|	�}
|	jd�s�|	jd�r�t|	�qVt|
�t|	d�}z|j|�Wd|j�|jd?}|rftj|�rf|d	@rftj|	d
t�d	B�nXqVWWd|j�XdS(s�
    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.
    Rxt
allowZip64iR�s\twbNiiIi�(R%RytzipfiletZipFileRrRtnamelisttinfolistR{RzRR0R5RltdirnameR�twriteR�t
external_attrRFtS_ISREGRIR�(
R{R�tflattentzipfptziptleadingtinfotnametdatatfnRER|tmode((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR �s0	
	



'cC@s�t|�|j�jd�s4|j�jd�r=d}np|j�jt�r[d}nR|j�jt�ryd}n4|j�jd�r�d}ntjd|�d	}tj||�}z�t	g|j
�D]}|jd
kr�|j^q��}x�|j
�D]�}|j}|d
kr'qn|r@t|�d}nt
jj||�}|j�rnt|�q|j�r�y|j||�Wq�tk
r�}tjd||j|�qq�Xqy|j|�}	Wn5ttfk
r
}tjd||j|�qnXtt
jj|��t|d
��}
tj|	|
�WdQX|	j�|j||�|jd@rt
j|dt�dB�qqWWd|j�XdS(s�
    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.
    s.gzs.tgzsr:gzsr:bz2sr:xzs.tartrs-Cannot determine compression type for file %ssr:*tpax_global_headeris/In the tar file %s the member %s is invalid: %sR�NiIi�(R%RkR�tBZ2_EXTENSIONSt
XZ_EXTENSIONStloggertwarningttarfileRyRt
getmembersR�RR0R5RlRotissymt_extract_memberRitextractfiletKeyErrorR<R�RCtcopyfileobjR�tutimeR�RIR�(R{R�R�ttartmemberR�R�R5texcR|tdestfp((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR!sb	
*				
!	



&cC@s(tjj|�}|dksB|j�jt�sBtj|�rbt||d|jd��n�|dks�t	j
|�s�|j�jttt
�r�t||�nz|r�|jd�r�tt|��r�ddlm}|d|j�j|�n&tjd	|||�td
|��dS(Nsapplication/zipR�s.whlsapplication/x-gzips	text/htmli(t
Subversionssvn+sZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formats%Cannot determine archive format of %s(R0R5R�RkR�tZIP_EXTENSIONSR�t
is_zipfileR R�t
is_tarfiletTAR_EXTENSIONSR�R�R!RVRRtpip.vcs.subversionR�turlR�R�tcriticalR(R{R�tcontent_typetlinkR�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR"Os,
traisecC@s�|rd}n	tj}|dkr�g}xd|D]\}	d|	ksgd|	ksgd|	ksgd|	kr�d|	jdd�}	n|j|	�q1Wdj|�}ntjd|�tj	j
�}
|r�|
j|�ny4tj|dtj
d	dd
|d|d|
�}Wn)tk
r7}tjd
||��nX|dk	r�g}
x�tr�t|jj��}|srPn|j�}|
j|d�tj�tjkr�tj|�qM|dk	rM|j�qMqMWn|j�|dk	r|jr|jd�q|jd�n|jr�|dkr�tj�tjkrq|rqtjd|�tjdj|
�d�ntd||j|f��q�|dkr�tjd||j|�q�|dkr�q�tdt |���n|s�dj|
�SdS(Nt s
t"t's"%s"s\"sRunning command %ststderrtstdintstdouttcwdtenvs#Error %s while executing command %sterrortdoneR�s Complete output from command %s:R`s)
----------------------------------------s,Command "%s" failed with error code %s in %stwarns$Command "%s" had error code %s in %stignoresInvalid value: on_returncode=%s(!R�t
subprocesstPIPERMR�RlR�tdebugR0RatcopytupdatetPopentSTDOUTRiR�RrRR�treadlinetrstriptgetEffectiveLeveltstd_loggingtDEBUGtspintwaitt
returncodetfinishR�RR�t
ValueErrortrepr(tcmdtshow_stdoutR�t
on_returncodetcommand_desct
extra_environtspinnerR�t	cmd_partstpartR�tprocR�t
all_outputtline((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR#psz		
0
	
		
cC@s�t|d��}|j�}WdQXdtjt�dg}x9|D]1}y|j|�}Wntk
rrqCnXPqCWt|�tks�t	�|S(sRReturn the contents of *filename*.

    Try to decode the file contents with utf-8, the preferred system encoding
    (e.g., cp1252 on some Windows machines), and latin1, in that order.
    Decoding a byte string with latin1 will never raise an error. In the worst
    case, the returned string will contain some garbage characters.

    RxNsutf-8tlatin1(
RyRztlocaletgetpreferredencodingRpRRtUnicodeDecodeErrorttypeRntAssertionError(R{R|R�t	encodingstenc((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytread_text_file�s	

cC@stj|�t|�dS(N(R0R1R
(t	build_dir((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt_make_build_dir�s
tFakeFilecB@s)eZdZd�Zd�Zd�ZRS(sQWrap a list of lines in an object with readline() to make
    ConfigParser happy.cC@sd�|D�|_dS(Ncs@s|]}|VqdS(N((t.0tl((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pys	<genexpr>�s(t_gen(tselftlines((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt__init__�scC@sLy3yt|j�SWntk
r1|jj�SXWntk
rGdSXdS(NR`(tnextR-t	NameErrort
StopIteration(R.((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR	�s

cC@s|jS(N(R-(R.((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt__iter__�s(t__name__t
__module__t__doc__R0R	R4(((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR*�s			t
StreamWrappercB@s&eZed��Zed��ZRS(cC@s||_|�S(N(torig_stream(tclsR9((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytfrom_streams	cC@s
|jjS(N(R9tencoding(R.((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR<
s(R5R6tclassmethodR;tpropertyR<(((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR8scc@sRtt|�}tt|tj|��ztt|�VWdtt||�XdS(s�Return a context manager used by captured_stdout/stdin/stderr
    that temporarily replaces the sys stream *stream_name* with a StringIO.

    Taken from Lib/support/__init__.py in the CPython repo.
    N(tgetattrR9tsetattrR8R;(tstream_nametorig_stdout((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytcaptured_outputs
cC@s
td�S(s�Capture the output of sys.stdout:

       with captured_stdout() as stdout:
           print('hello')
       self.assertEqual(stdout.getvalue(), 'hello
')

    Taken from Lib/support/__init__.py in the CPython repo.
    R�(RC(((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR$s	tcached_propertycB@s eZdZd�Zd�ZRS(s�A property that is only computed once per instance and then replaces
       itself with an ordinary attribute. Deleting the attribute resets the
       property.

       Source: https://github.com/bottlepy/bottle/blob/0.11.5/bottle.py#L175
    cC@st|d�|_||_dS(NR7(R?R7RK(R.RK((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR02scC@s4|dkr|S|j|�}|j|jj<|S(N(R�RKt__dict__R5(R.tobjR:tvalue((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt__get__6s (R5R6R7R0RH(((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyRD*s	cC@s\tjj|�}|dkr-tj�}ntj|�}|j|�}|rX|jSdS(sCGet the installed version of dist_name avoiding pkg_resources cacheN(RtRequirementtparseR�t
WorkingSetR�tversion(t	dist_nametlookup_dirstreqR�R�((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyR(>scC@st|dd�dS(sConsume an iterable at C speed.tmaxleniN(R(titerator((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pytconsumeRs(s.tar.bz2s.tbz(s.tar.xzs.txzs.tlzs.tar.lzs	.tar.lzma(s.zips.whl(s.tar.gzs.tgzs.tar(gt
__future__RtcollectionsRt
contextlibR3tioR tloggingRRtR0R�RCRFRR9R�R�tpip.exceptionsRt
pip.compatRRRt
pip.locationsRRRR	R
tpip._vendorRtpip._vendor.six.movesRtpip._vendor.sixR
tpip._vendor.retryingRRRt__all__t	getLoggerR5R�R�R�R�R�R&R'tbz2R*RtlzmaR/R%RRpRRDRRRgRRRRRtDEFAULT_BUFFER_SIZER�RRRrRRRR�R�R�R�R�R�R�R�RR�R R!R"R�R#R'R)tobjectR*R8tcontextmanagerRCR$RDR(RR(((s6/usr/lib/python2.7/site-packages/pip/utils/__init__.pyt<module>s�(			


				
						
					
							
		5	%			+	L	!_		
	

Zerion Mini Shell 1.0