Your IP : 3.145.196.141


Current Path : /proc/self/root/usr/lib/python3.6/site-packages/pip/req/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3.6/site-packages/pip/req/__pycache__/req_uninstall.cpython-36.pyc

3

�Pf��@s�ddlmZddlZddlZddlZddlmZmZmZddl	m
Z
ddlmZm
Z
mZmZmZddlmZeje�ZGdd�de�ZGd	d
�d
e�ZdS)�)�absolute_importN)�uses_pycache�WINDOWS�cache_from_source)�UninstallationError)�rmtree�ask�is_local�renames�normalize_path)�
indent_logc@sZeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
dd�Zdd�ZdS)�UninstallPathSetzMA set of file paths to be removed in the uninstallation of a
    requirement.cCs,t�|_t�|_i|_||_d|_g|_dS)N)�set�paths�_refuse�pth�dist�save_dir�_moved_paths)�selfr�r�#/usr/lib/python3.6/req_uninstall.py�__init__szUninstallPathSet.__init__cCst|�S)zs
        Return True if the given path is one we are permitted to
        remove/modify, False otherwise.

        )r	)r�pathrrr�
_permittedszUninstallPathSet._permittedcCs�tjj|�\}}tjjt|�tjj|��}tjj|�s:dS|j|�rR|jj	|�n|j
j	|�tjj|�ddkr�tr�|j	t
|��dS)N�z.py)�osr�split�joinr�normcase�existsrr�addr�splitextrr)rr�head�tailrrrr!#s
zUninstallPathSet.addcCsLt|�}|j|�r<||jkr*t|�|j|<|j|j|�n|jj|�dS)N)rrr�UninstallPthEntriesr!r)r�pth_file�entryrrr�add_pth6s

zUninstallPathSet.add_pthcs@t�}x4t|td�D]$�t�fdd�|D��s|j��qW|S)z�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.)�keycs4g|],}�j|�o.�t|jtjj��tjjk�qSr)�
startswith�len�rstriprr�sep)�.0Z	shortpath)rrr�
<listcomp>Gsz,UninstallPathSet.compact.<locals>.<listcomp>)r�sortedr+�anyr!)rrZshort_pathsr)rr�compact?s

zUninstallPathSet.compactcCs&tjj|jtjj|�djtjj��S)Nr)rrrr�
splitdrive�lstripr-)rrrrr�_stashMszUninstallPathSet._stashFcCs:|jstjd|jj�dStjd|jj|jj�t���t|j|j��}|rRd}n"x|D]}tj|�qXWt	dd
�}|j
r�tjd�x|j|j
�D]}tj|�q�W|dk�r,tjdd	d
�|_
x8|D]0}|j|�}tjd|�|jj|�t||�q�Wx|jj�D]}|j��qWtjd|jj|jj�WdQRXdS)z[Remove paths in ``self.paths`` with confirmation (unless
        ``auto_confirm`` is True).z7Can't uninstall '%s'. No files were found to uninstall.NzUninstalling %s-%s:�yzProceed (y/n)? �nz.Not removing or modifying (outside of prefix):z
-uninstallzpip-)�suffix�prefixzRemoving file or directory %szSuccessfully uninstalled %s-%s)r6r7)r�logger�infor�project_name�versionrr0r2rr�tempfileZmkdtemprr5�debugr�appendr
r�values�remove)rZauto_confirmrZresponser�new_pathrrrrrBQs@







zUninstallPathSet.removecCs~|jdkrtjd|jj�dStjd|jj�x.|jD]$}|j|�}tjd|�t	||�q6Wx|j
j�D]}|j�qjWdS)z1Rollback the changes previously made by remove().Nz'Can't roll back %s; was not uninstalledFzRolling back uninstall of %szReplacing %s)
rr:�errorrr<r;rr5r?r
rrA�rollback)rrZtmp_pathrrrrrE{s


zUninstallPathSet.rollbackcCs$|jdk	r t|j�d|_g|_dS)z?Remove temporary save dir: rollback will no longer be possible.N)rrr)rrrr�commit�s

zUninstallPathSet.commitN)F)
�__name__�
__module__�__qualname__�__doc__rrr!r(r2r5rBrErFrrrrr
s	
*r
c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r%cCs0tjj|�std|��||_t�|_d|_dS)Nz.Cannot remove entries from nonexistent file %s)rr�isfiler�filer�entries�_saved_lines)rr&rrrr�s
zUninstallPthEntries.__init__cCs>tjj|�}tr.tjj|�dr.|jdd�}|jj|�dS)Nr�\�/)rrrrr3�replacerMr!)rr'rrrr!�szUninstallPthEntries.addcCs�tjd|j�t|jd��}|j�}||_WdQRXtdd�|D��rLd}nd}xH|jD]>}y$tjd|�|j||j	d��WqXt
k
r�YqXXqXWt|jd	��}|j|�WdQRXdS)
NzRemoving pth entries from %s:�rbcss|]}d|kVqdS)s
Nr)r.�linerrr�	<genexpr>�sz-UninstallPthEntries.remove.<locals>.<genexpr>z
�
zRemoving entry: %szutf-8�wb)r:r?rL�open�	readlinesrNr1rMrB�encode�
ValueError�
writelines)r�fh�linesZendliner'rrrrB�s
zUninstallPthEntries.removec	CsR|jdkrtjd|j�dStjd|j�t|jd��}|j|j�WdQRXdS)Nz.Cannot roll back changes to %s, none were madeFz!Rolling %s back to previous staterVT)rNr:rDrLr?rWr[)rr\rrrrE�s

zUninstallPthEntries.rollbackN)rGrHrIrr!rBrErrrrr%�s	
r%)Z
__future__rZloggingrr>Z
pip.compatrrrZpip.exceptionsrZ	pip.utilsrrr	r
rZpip.utils.loggingrZ	getLoggerrGr:�objectr
r%rrrr�<module>s


?>