AlkantarClanX12

Your IP : 3.144.93.34


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

�
�Re�9�@s�ddlZddlZddlZddlZddlZddlZddlmZmZm	Z	ddl
mZddlm
Z
ddlmZGdd�de�ZdS)�N)�display_path�
backup_dir�rmtree)�logger)�InstallationError)�Commandcs�eZdZdZdZdZdZ�fdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Z�S)�
ZipCommandzZip individual packages.�zipz#
     %prog [options] <package> ...z$DEPRECATED. Zip individual packages.c
s9tt|�j||�|jdkrM|jjddddddd�n(|jjd	dd
dddddd
�|jjddddddd�|jjdddddddd�|jjddddddd�|jjddddddd�|jjdddddd�|jjd|j�dS) Nr	z--unzip�action�
store_true�dest�unzip�helpz"Unzip (rather than zip) a package.z--zip�store_false�defaultTz"Zip (rather than unzip) a package.z--no-pyc�no_pyczEDo not include .pyc files in zip files (useful on Google App Engine).z-lz--list�listz2List the packages available, and their zip status.z--sort-files�
sort_fileszDWith --list, sort packages according to how many files they contain.z--path�append�pathsz?Restrict operations to the given paths (may include wildcards).z-nz
--simulatez0Do not actually perform the zip/unzip operation.r)�superr�__init__�name�cmd_opts�
add_option�parser�insert_option_group)�self�args�kw)�	__class__��+/tmp/pip-ztkk0jow-build/pip/commands/zip.pyrsL	
								zZipCommand.__init__cCsp|jstjSg}t�}x�tjD]�}tjjtjj|��}x�|jD]�}tjjtjj|��}d|kr�tjt	j
|d�|�r�|j|�|j|�Pq�qW|j
|�rW|j|�|j|�PqWqWWtjd|dj|j�f�q)WxJ|jD]?}||kr)d|kr)|j|�tjd|�q)q)W|S)z:All the entries of sys.path, possibly restricted by --path�*z,Skipping path %s because it doesn't match %sz, zDAdding path %s because it doesn't match anything already on sys.path)�select_paths�sys�path�set�os�normcase�abspath�re�search�fnmatch�	translater�add�
startswithr�debug�join)r�result�	match_anyr&�matchr!r!r"r>s2		



	
	zZipCommand.pathscCsVtjdd�|j|_|j|_|jrA|j||�S|sVtd��ng}x�|D]�}|j|�\}}|jr�t	j
j|�r�td||f��n6|jr�t	j
j|�r�td||f��n|j||f�qcWd}xJ|D]B\}}|jr6|j
||�}q|j|||j�}qW|S)Nz1.7z_DEPRECATION: 'pip zip' and 'pip unzip` are deprecated, and will be removed in a future release.z2You must give at least one package to zip or unzipz;The module %s (in %s) is not a zip file; cannot be unzippedz:The module %s (in %s) is not a directory; cannot be zipped)r�
deprecatedrr$�simulaterr�find_packager
r(r&�isdirr�
unzip_package�zip_packager)r�optionsr�packages�arg�module_name�filename�last_statusr!r!r"�run\s4	
	zZipCommand.runcCs�tjj|�}tjj|�rPtj|�rPtd|||f��ntjj|�}||j�kr�tj	dt
|�t
|�t
|�f�ntjd|t
|�f�|jr�tjd�dStj
d7_
z�tj|�}g}x|j�D]}|j}|j|tjj�r�|j|�}	tjj||�}
tjjtjj|
��s�tjtjj|
��n|	r�|
jtjj�r�tjj|
�s�tj|
�q�qt|
d�}|j|	�|j�q|j||j|�f�qW|j�|sbtjdt
|��tj|�|j|�n`tjd|t
|�f�tj|d	�}x$|D]\}}	|j||	�q�W|j�Wdtj
d8_
XdS)
Nz3Module %s (in %s) isn't located in a zip file in %sz/Unpacking %s into %s, but %s is not on sys.pathzUnzipping %s (in %s)z3Skipping remaining operations because of --simulate��wbzRemoving now-empty zip file %sz(Removing entries in %s/ from zip file %s�w) r(r&�dirname�isfile�zipfile�
is_zipfilerrr�warnr�notifyr7�indent�ZipFile�infolistr@r0�sep�readr2�exists�makedirs�endswith�open�write�closer�info�unlink�remove_filename_from_pth�writestr)rr?r@�zip_filename�package_pathr	�to_saverWr�contentr�fr!r!r"r:{sX"	
	

 

zZipCommand.unzip_packagecCsN|}tjd|t|�f�tjd7_|jd�rJ|}n
|d}z�||kr�t|�}tjd||f�|js�tj||�q�nyvtj	dt|��|js�t
j|d�}|j|dd	�x�t
j|�D]�\}}}	|r)d
d�|	D�}	nx�|df|	d
fgD]�\}
}x�|
D]}t
jj||�}
t
jj||t|�d�jt
jj�|�}|r�|j|dd	�qU|j|
|�qUWqBWq�W|j�ntj	dt|��|jst|�nWn�YnX|j|�Wdtjd8_XdS)NzZip %s (in %s)rCz.eggz.zipzMoving %s aside to %szCreating zip file in %srE�/�cSs+g|]!}|j�jd�s|�qS)z.pyc)�lowerrS)�.0r_r!r!r"�
<listcomp>�s	z*ZipCommand.zip_package.<locals>.<listcomp>TFzRemoving old directory %s)rrKrrLrSrr7�shutil�moverWrHrMrZr(�walkr&r2�len�lstriprOrUrVr�add_filename_to_pth)rr?r@r�
orig_filename�
dest_filenamer	�dirpath�dirnames�	filenames�fns�is_dir�fn�fullrr!r!r"r;�sF	
		%
7
	zZipCommand.zip_packagecsx�|j�D]�}t|d�}|j�}|j��fdd�|D�}||kr
tjdt��t|�f�dd�|D�s�tjdt|��|js�tj	|�q�n2|js�t|d�}|j
|�|j�ndSq
Wtjdt���dS)	N�rcs(g|]}|j��kr|�qSr!)�strip)rc�l)r@r!r"rd�s	z7ZipCommand.remove_filename_from_pth.<locals>.<listcomp>z*Removing reference to %s from .pth file %scSsg|]}|r|�qSr!r!)rc�liner!r!r"rd�s	z %s file would be empty: deletingrDz.Cannot find a reference to %s in any .pth file)�	pth_filesrT�	readlinesrVrrWrr7r(rX�
writelinesrJ)rr@�pthr_�lines�	new_linesr!)r@r"rY�s$
			

z#ZipCommand.remove_filename_from_pthcCs�tjj|�}|d}||j�krHtjdt|��n|js�tjj|�r�t	|�}|j
�}|j�|r�|djd�r�|dd7<n|j
|d�n
|dg}t	|d�}|j|�|j�ndS)Nz.pthz.Adding .pth file %s, but it is not on sys.path��
rD���r�)r(r&rFrrrJrr7rQrTryrVrSrrz)rr@r&rr_r|r!r!r"rj�s 
	


zZipCommand.add_filename_to_pthccs�x�|j�D]r}tjj|�s
tjj|�r?q
nx=tj|�D],}|jd�rOtjj||�VqOqOWq
WdS)Nz.pth)rr(r&rQr9�listdirrSr2)rr&r@r!r!r"rxs&zZipCommand.pth_filescCs�x�|j�D]�}tjj||�}tjj|�rD||fStjj|�r
tj|�r
tj|d�}y |j	tjj|d��Wnt
k
r�YnX|j�||fS|j�q
q
Wtd|��dS)Nrtz__init__.pyz!No package with the name %s found)
rr(r&r2rQr9rHrIrMrP�KeyErrorrVr)r�packager&rsr	r!r!r"r8s
" 


zZipCommand.find_packagecCsD|rtd��nx(t|j��D]}tjj|�sFq(ntjj|jtjj��}tjj	|�r�t
j|�r�tjj|�|j�kr(t
jdt|��q(q(n|dkr|dkr|jdd�jd�rq(nt
jdt|��t
jd	7_g}g}z�x�ttj|��D]�}tjj|�d
j�}|dkrqKn|dkr�t
jdt|��qKntjj||�}	tjj|	�r�|j||j|	�f�qKt
j|	�r
|j|�qKt
jdt|��qKW|r�t
jd�t
jd	7_z"x|D]}t
j|�qTWWdt
jd	8_Xn
t
jd�|r|jr�|jddd��nt
jd�t
jd	7_z2x+|D]#\}}
t
jd||
f�q�WWdt
jd	8_Xn
t
jd�Wdt
jd	8_Xq(WdS)Nz'You cannot give an argument with --listzZipped egg: %sz
site-packagesz
dist-packages�\r`z
lib/pythonzIn %s:rCr~�.pth�	.egg-info�	.egg-linkz.pyz Not displaying %s: not a packagezUnknown file: %szZipped packages:zNo zipped packages.�keycSs	|dS)Nr~r!)�xr!r!r"�<lambda>Lsz!ZipCommand.list.<locals>.<lambda>zUnzipped packages:z%s  (%i files)zNo unzipped packages.)r�r�r�)r�sortedrr(r&rQ�basename�rstriprOrGrHrIrFrrKr�replacerSrLr��splitextrbrWr2r9r�
count_packager�sort)rr<rr&r��zipped�unzippedr@�extrs�countr!r!r"rsf!!


	
zZipCommand.listcCsPd}xCtj|�D]2\}}}dd�|D�}|t|�7}qW|S)NrcSs+g|]!}|j�jd�s|�qS)z.pyc)rbrS)rcr_r!r!r"rd\s	z,ZipCommand.count_package.<locals>.<listcomp>)r(rgrh)rr&�totalrmrnror!r!r"r�Ys
zZipCommand.count_package)�__name__�
__module__�__qualname__�__doc__r�usage�summaryrrrBr:r;rYrjrxr8rr�r!r!)r r"r
s*3,;r)r%r+r-r(rerH�pip.utilrrr�pip.logr�pip.exceptionsr�pip.basecommandrrr!r!r!r"�<module>s