????

Your IP : 216.73.216.152


Current Path : /usr/lib/python2.7/site-packages/pip/_internal/req/
Upload File :
Current File : //usr/lib/python2.7/site-packages/pip/_internal/req/req_uninstall.pyc

�
}�\]c@@s
ddlmZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZddlmZmZmZddlmZddlmZmZmZmZmZmZmZmZmZdd	lm Z m!Z!dd
l"m#Z#e#ryddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/nej0e1�Z2d
�Z3d�Z4e4d��Z5d�Z6d�Z7d�Z8de9fd��YZ:de9fd��YZ;de9fd��YZ<dS(i(tabsolute_importN(t
pkg_resources(tUninstallationError(tbin_pytbin_user(tWINDOWStcache_from_sourcetuses_pycache(t
indent_log(	tFakeFiletasktdist_in_usersitet
dist_is_localt
egg_link_pathtis_localtnormalize_pathtrenamestrmtree(tAdjacentTempDirectoryt
TempDirectory(tMYPY_CHECK_RUNNING(	tAnytCallabletDicttIterabletIteratortListtOptionaltSettTuple(tDistributioncC@s�t|�rt}nt}tjj||�}|g}tr�|j|d�|j|d�|r{|j|d�q�|j|d�n|S(s�Create the fully qualified name of the files created by
    {console,gui}_scripts for the given ``dist``.
    Returns the list of file names
    s.exes
.exe.manifests-script.pyws
-script.py(RRRtostpathtjoinRtappend(tdisttscript_nametis_guitbin_dirtexe_nametpaths_to_remove((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt
_script_names s		c@s"tj���fd��}|S(Nc?@sHt�}x8�||�D]'}||kr|j|�|VqqWdS(N(tsettadd(targstkwtseentitem(tfn(s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytunique8s
	
(t	functoolstwraps(R0R1((R0s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt_unique6scc@s�tjt|jd���}x�|D]�}tjj|j|d�}|V|jd�r%tjj	|�\}}|d }tjj||d�}|Vtjj||d�}|Vq%q%WdS(s
    Yield all the uninstallation paths for dist based on RECORD-without-.py[co]

    Yield paths to all the files in RECORD. For each .py file in RECORD, add
    the .pyc and .pyo in the same directory.

    UninstallPathSet.add() takes care of the __pycache__ .py[co].
    tRECORDis.pyi����s.pycs.pyoN(
tcsvtreaderR	tget_metadata_linesRR R!tlocationtendswithtsplit(R#trtrowR tdnR0tbase((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytuninstallation_pathsCs

c@sktjj�t�}xOt|dt�D];�t��fd�|D��}|s(|j��q(q(W|S(s�Compact a path set to contain the minimal number of paths
    necessary to contain all paths in the set. If /a/path/ and
    /a/path/to/a/file.txt are both in the set, leave only the
    shorter path.tkeyc3@sO|]E}�j|jd��oF�t|jd�j����kVqdS(t*N(t
startswithtrstriptlen(t.0t	shortpath(R tsep(s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pys	<genexpr>fs(RR RHR*tsortedREtanyR+(tpathstshort_pathstshould_skip((R RHs>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytcompact[s	
c	@sRtd�|D��}t|�}ttd�|j�D��dt�}t�}d��x�|D]��t�fd�|D��r�qcnt�}t�}xftj��D]U\�}}|j���fd�|D��|j���fd�|D��q�W||sc|j	|�|j
�tj�qcqcWtt|j
|��|BS(s�Returns a set containing the paths that need to be renamed.

    This set may include directories when the original sequence of paths
    included every file on disk.
    cs@s'|]}tjj|�|fVqdS(N(RR tnormcase(RFtp((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pys	<genexpr>vscs@s%|]}tjj|�dVqdS(iN(RR R;(RFRP((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pys	<genexpr>xsRAcW@stjjtjj|��S(N(RR ROR!(ta((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt	norm_join|sc3@s*|] }tjj��j|�VqdS(N(RR RORC(RFtw(troot(s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pys	<genexpr>�sc3@s!|]}���|�VqdS(N((RFtd(tdirnameRRRT(s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pys	<genexpr>�sc3@s!|]}���|�VqdS(N((RFtf(RVRRRT(s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pys	<genexpr>�s(tdictR*RItvaluesRERJRtwalktupdatetdifference_updateR+RHtmapt__getitem__(	RKtcase_mapt	remainingt	uncheckedt	wildcardst	all_filestall_subdirstsubdirstfiles((RVRRRTs>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytcompress_for_renameos*		

		

c
C@st|�}t�}t�}t�}xg|D]_}|jd�rIq.n|jd�sdd|kr�|jtjj|��n|j|�q.Wtttjj|��}t|�}x�|D]�}x�tj	|�D]�\}}	}
xr|
D]j}|jd�rq�ntjj
||�}tjj|�r�tjj|�|kr�|j|�q�q�Wq�Wq�W|d�|D�B}||fS(ssReturns a tuple of 2 sets of which paths to display to user

    The first set contains paths that would be deleted. Files of a package
    are not added and the top-level directory of the package has a '*' added
    at the end - to signify that all it's contents are removed.

    The second set contains files that would have been skipped in the above
    folders.
    s.pycs__init__.pys
.dist-infocS@s%h|]}tjj|d��qS(RB(RR R!(RFtfolder((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pys	<setcomp>�s	(R*R:R+RR RVR]RORNRZR!tisfile(
RKtwill_removet	will_skiptfoldersRfR t_normcased_filesRhtdirpatht_tdirfilestfnametfile_((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytcompress_for_output_listing�s0			


tStashedUninstallPathSetcB@sSeZdZd�Zd�Zd�Zd�Zd�Zd�Ze	d��Z
RS(sWA set of file rename operations to stash files while
    tentatively uninstalling them.cC@si|_g|_dS(N(t
_save_dirst_moves(tself((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt__init__�s	cC@sgyt|�}|j�Wn*tk
rFtdd�}|j�nX||jtjj|�<|jS(s�Stashes a directory.

        Directories are stashed adjacent to their original location if
        possible, or else moved/copied into the user's temp dir.tkindt	uninstall(RtcreatetOSErrorRRuRR RO(RwR tsave_dir((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt_get_directory_stash�s
cC@stjj|�}tjj|�d}}d}x�||kr�y|j|}PWntk
renXtjj|�|}}q4Wtjj|�}tdd�}|j�||j|<tjj	||�}|r�|tjj
kr�tjj|j|�S|jS(s�Stashes a file.

        If no root has been provided, one will be created for the directory
        in the user's temp directory.RyRzN(RR RORVtNoneRutKeyErrorRR{trelpathtcurdirR!(RwR theadtold_headR}R�((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt_get_file_stash�s$



cC@s�tjj|�r$|j|�}n|j|�}|jj||f�tjj|�r}tjj|�r}tj|�nt||�|S(sDStashes the directory or file and returns its new location.
        (	RR tisdirR~R�RvR"trmdirR(RwR tnew_path((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytstashs$
cC@s@x'|jj�D]\}}|j�qWg|_i|_dS(s0Commits the uninstall by removing stashed files.N(RutitemstcleanupRv(RwRoR}((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytcommits	cC@s�x!|jD]}tjd|�q
Wx�|jD]�\}}yetjd||�tjj|�rrtj|�ntjj	|�r�t
|�nt||�Wq.tk
r�}tj
d|�tjd|�q.Xq.W|j�dS(s2Undoes the uninstall by moving stashed files back.sMoving to %s
 from %ssReplacing %s from %ssFailed to restore %ss
Exception: %sN(RvtloggingtinfotloggertdebugRR RitunlinkR�RRR|terrorR�(RwRPR�R tex((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytrollback s
cC@s
t|j�S(N(tboolRv(Rw((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytcan_rollback4s(t__name__t
__module__t__doc__RxR~R�R�R�R�tpropertyR�(((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyRt�s							tUninstallPathSetcB@skeZdZd�Zd�Zd�Zd�Zeed�Zd�Z	d�Z
d�Zed	��Z
RS(
sMA set of file paths to be removed in the uninstallation of a
    requirement.cC@s:t�|_t�|_i|_||_t�|_dS(N(R*RKt_refusetpthR#Rtt_moved_paths(RwR#((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyRx=s
		cC@s
t|�S(ss
        Return True if the given path is one we are permitted to
        remove/modify, False otherwise.

        (R(RwR ((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt
_permittedEscC@s�tjj|�\}}tjjt|�tjj|��}tjj|�sUdS|j|�rw|jj	|�n|j
j	|�tjj|�ddkr�tr�|j	t
|��ndS(Nis.py(RR R;R!RROtexistsR�RKR+R�tsplitextRR(RwR R�ttail((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR+Ns'"cC@skt|�}|j|�rW||jkr@t|�|j|<n|j|j|�n|jj|�dS(N(RR�R�tUninstallPthEntriesR+R�(Rwtpth_filetentry((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pytadd_pthbsc	C@s�|js#tjd|jj�dS|jjd|jj}tjd|�t���|sl|j|�r�|j}t	|j�}x7t
t|��D]#}|j|�tj
d|�q�Wx!|jj�D]}|j�q�Wtjd|�nWdQXdS(s[Remove paths in ``self.paths`` with confirmation (unless
        ``auto_confirm`` is True).s7Can't uninstall '%s'. No files were found to uninstall.Nt-sUninstalling %s:sRemoving file or directory %ssSuccessfully uninstalled %s(RKR�R�R#tproject_nametversionRt_allowed_to_proceedR�RgRIRNR�R�R�RYtremove(Rwtauto_confirmtverbosetdist_name_versiontmovedt
for_renameR R�((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR�ls"	

	
cC@s�d�}|s't|j�\}}nt|j�}t�}|d|�|d|�|d|j�|r�|dt|j��ntdd	�dkS(
sIDisplay which files would be deleted and prompt for confirmation
        cS@sU|s
dStj|�t��/x'tt|��D]}tj|�q4WWdQXdS(N(R�R�RRIRN(tmsgRKR ((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt_display�s

s
Would remove:s+Would not remove (might be manually added):s%Would not remove (outside of prefix):sWill actually move:sProceed (y/n)? tytn(R�R�(RsRKR*R�RgR
(RwR�R�RjRk((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR��s	
	

cC@sq|jjs&tjd|jj�dStjd|jj�|jj�x!|jj	�D]}|j�qYWdS(s1Rollback the changes previously made by remove().s'Can't roll back %s; was not uninstalledNsRolling back uninstall of %s(
R�R�R�R�R#R�R�R�R�RY(RwR�((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR��s

cC@s|jj�dS(s?Remove temporary save dir: rollback will no longer be possible.N(R�R�(Rw((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR��scC@sMt|j�}t|�sAtjd|j|tj�||�S|d�tj	d�tj	d�hD�kr�tjd|j|�||�S||�}t
|�}djtj
|j��}|jo�tjj|j�}t|jdd�}|rl|jjd�rl|jj|�rl|j|j�|jd	�r�x'|jd	�j�D]7}tjjtjj|j|��}	|j|	�qUWq|jd
�r|jd�r�|jd�}
ng}
x�g|jd
�j�D]}|r�||
kr�|^q�D]^}tjj|j|�}	|j|	�|j|	d�|j|	d
�|j|	d�qWqn�|r�tdj|j���ny|jjd�r|j|j�tjj|j�d}
tjjtjj|j�d�}|j |d|
�n|rB|jjd�rBx�t!|�D]}	|j|	�q(Wn�|r�t"|d��%}tjj#|j$�j%��}WdQX||jks�t&d||j|jf��|j|�tjjtjj|�d�}|j ||j�ntj'd||j�|jd�r�|j(d�r�xz|j)d�D]f}t*|�rOt+}nt,}|jtjj||��t-r4|jtjj||�d�q4q4Wng}|j.dd�}x-|j/�D]}|j0t1||t2��q�W|j.dd�}x-|j/�D]}|j0t1||t3��qWx|D]}|j|�q2W|S(Ns1Not uninstalling %s at %s, outside environment %scS@sh|]}|r|�qS(((RFRP((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pys	<setcomp>�s	tstdlibt
platstdlibs<Not uninstalling %s at %s, as it is in the standard library.s{}.egg-infoR s	.egg-infosinstalled-files.txts
top_level.txtsnamespace_packages.txts.pys.pycs.pyos�Cannot uninstall {!r}. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.s.eggiseasy-install.pths./s
.dist-infoR<s;Egg-link %s does not match installed location of %s (at %s)s)Not sure how to uninstall: %s - Check: %stscriptss.battgrouptconsole_scriptstgui_scripts(4RR9RR�R�RAtsystprefixt	sysconfigtget_pathR
tformatRtto_filenameR�tegg_infoRR R�tgetattrt	_providerRR:R+thas_metadatatget_metadatat
splitlinestnormpathR!RR;RVR�R@topenROtreadlinetstriptAssertionErrorR�tmetadata_isdirtmetadata_listdirRRRRt
get_entry_maptkeystextendR)tFalsetTrue(tclsR#t	dist_pathR(tdevelop_egg_linktdevelop_egg_link_egg_infotegg_info_existstdistutils_egg_infotinstalled_fileR t
namespacesRPt
top_level_pkgteasy_install_eggteasy_install_pthtfhtlink_pointertscriptR&t_scripts_to_removeR�tnameR�ts((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt	from_dist�s�


		"
	$
	
	*
(R�R�R�RxR�R+R�R�R�R�R�R�tclassmethodR�(((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR�:s					
 			R�cB@s,eZd�Zd�Zd�Zd�ZRS(cC@sGtjj|�s%td|��n||_t�|_d|_dS(Ns.Cannot remove entries from nonexistent file %s(	RR RiRtfileR*tentriesRt_saved_lines(RwR�((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyRxCs	cC@sXtjj|�}trDtjj|�drD|jdd�}n|jj|�dS(Nis\t/(RR RORt
splitdrivetreplaceR�R+(RwR�((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR+MscC@s+tjd|j�t|jd��}|j�}||_WdQXtd�|D��rbd}nd}|r�|dj|jd��r�|d|jd�|d<nxS|j	D]H}y.tjd|�|j
||jd��Wq�tk
r�q�Xq�Wt|jd	��}|j|�WdQXdS(
NsRemoving pth entries from %s:trbcs@s|]}d|kVqdS(s
N((RFtline((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pys	<genexpr>_ss
s
i����sutf-8sRemoving entry: %stwb(
R�R�R�R�t	readlinesR�RJR:tencodeR�R�t
ValueErrort
writelines(RwR�tlinestendlineR�((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR�Xs"	#
cC@sh|jdkr&tjd|j�tStjd|j�t|jd��}|j|j�WdQXt	S(Ns.Cannot roll back changes to %s, none were mades!Rolling %s back to previous stateR�(
R�RR�R�R�R�R�R�R�R�(RwR�((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR�os
(R�R�RxR+R�R�(((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyR�Bs	
		(=t
__future__RR6R2R�RR�R�tpip._vendorRtpip._internal.exceptionsRtpip._internal.locationsRRtpip._internal.utils.compatRRRtpip._internal.utils.loggingRtpip._internal.utils.miscR	R
RRR
RRRRtpip._internal.utils.temp_dirRRtpip._internal.utils.typingRttypingRRRRRRRRRtpip._vendor.pkg_resourcesRt	getLoggerR�R�R)R4R@RNRgRstobjectRtR�R�(((s>/tmp/pip-install-ewDPok/pip/pip/_internal/req/req_uninstall.pyt<module>s8@@		
		(	3p�