Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/Tools/scripts/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/Tools/scripts/__pycache__/patchcheck.cpython-34.pyc

�
e f��@s�ddlZddlZddlZddlZddlZddlZddlZddlZej	d�Z
dd�Zdddd�Zdd	�Z
ed
ddd
��dd��Zdd�Zedde�dd��Zedde�dd��Zejd�Zedde�dd��Zeddd�dd ��Zed!dd�d"d#��Zed$dd�d%d&��Zed'ddde�d(d)��Zed*ddde�d+d,��Zd-d.�Zed/kr�e�ndS)0�N�srcdircCs"dj||dkrdnd�S)z7Return 'N file(s)' with the proper plurality on 'file'.z	{} file{}��s�)�format)�count�r�=/opt/alt/python34/lib64/python3.4/Tools/scripts/patchcheck.py�n_files_strsr
Fcs���fdd�}|S)z*Decorator to output status info to stdout.cs����fdd�}|S)Ncs~tjj�d�tjj��||�}�rK�rKtd�n/�rdt�|��nt|rsdnd�|S)Nz ... �done�yesZNO)�sys�stdout�write�flush�print)�args�kwargs�result)�fxn�info�message�modalrr	�call_fxns

z/status.<locals>.decorated_fxn.<locals>.call_fxnr)rr)rrr)rr	�
decorated_fxnszstatus.<locals>.decorated_fxnr)rrrrr)rrrr	�statuss
rc	Cs_d}tj|j�dtjdtj��,}|j�\}}|jdkoT|SWdQXdS)z*Check if there are any applied MQ patches.zhg qappliedr�stderrrN)�
subprocess�Popen�split�PIPEZcommunicate�
returncode)�cmd�stZbstdout�_rrr	�mq_patches_applied's	r%z6Getting the list of files that have been added/changedrcCstt|��S)N)r
�len)�xrrr	�<lambda>2sr(cCs}tjjtjjtd��r{d}t�r=|d7}ntj|j�dtj	��}dd�|j
D�SWdQXn�tjjtjjtd��rld	}g}tj|j�dtj	���}x�|j
D]�}|j�j�}t
|dd
��}|jd�sq�n|dd�}d
|krQ|jd
d
�dj�}n|j|�q�WWdQX|Stjd�dS)z=Get the list of changed or added files from Mercurial or git.z.hgz(hg status --added --modified --no-statusz --rev qparentrcSs"g|]}|j�j��qSr)�decode�rstrip)�.0r'rrr	�
<listcomp>:s	z!changed_files.<locals>.<listcomp>Nz.gitzgit status --porcelain�ZMAU�z -> rz6need a Mercurial or git checkout to get modified files)�os�path�isdir�join�SRCDIRr%rrrr rr)r*�set�intersection�strip�appendr
�exit)r"r#�	filenames�liner�filenamerrr	�
changed_files1s*!	
!!!r<cCsrt|�}|dkr"t|�Sdjt|��g}x$|D]}|jdj|��qAWdj|�SdS)Nrz{}:z  {}�
)r&r
rr7r2)�
file_pathsr�linesr0rrr	�report_modified_filesOs

r@zFixing whitespacecCs dt_dd�|D�}|S)zAMake sure that the whitespace for .py files have been normalized.FcSsCg|]9}|jd�rtjtjjt|��r|�qS)z.py)�endswith�reindentZcheckr/r0r2r3)r+r0rrr	r,^s	z(normalize_whitespace.<locals>.<listcomp>)rBZ
makebackup)r>�fixedrrr	�normalize_whitespaceZs	rDzFixing C file whitespacecCs�g}xv|D]n}tjjt|�}t|d��}d|j�krRw
nWdQXtj|ddd�|j|�q
W|S)zReport if any C files �r�	N��verboseF)	r/r0r2r3�open�read�untabifyZprocessr7)r>rCr0�abspath�frrr	�normalize_c_whitespacecs
rNs\s+(\r?\n)$zFixing docs whitespacecCs�g}x�|D]�}tjjt|�}y�t|d��}|j�}WdQXdd�|D�}||kr�tj||d�t|d��}|j|�WdQX|j	|�nWq
t
k
r�}ztd||f�WYdd}~Xq
Xq
W|S)N�rbcSs"g|]}tjd|��qS)s\1)�ws_re�sub)r+r:rrr	r,{s	z-normalize_docs_whitespace.<locals>.<listcomp>z.bak�wbzCannot fix %s: %s)r/r0r2r3rI�	readlines�shutilZcopyfile�
writelinesr7�	Exceptionr)r>rCr0rLrMr?Z	new_lines�errrrr	�normalize_docs_whitespacess
+rXz
Docs modifiedrTcCs
t|�S)z9Report if any file in the Doc directory has been changed.)�bool)r>rrr	�
docs_modified�srZzMisc/ACKS updatedcCstjjdd�|kS)z$Check if Misc/ACKS has been changed.�Misc�ACKS)r/r0r2)r>rrr	�credit_given�sr]zMisc/NEWS updatedcCstjjdd�|kS)z$Check if Misc/NEWS has been changed.r[�NEWS)r/r0r2)r>rrr	�
reported_news�sr_zconfigure regeneratedcCs(d|kr d|krdSdSdSdS)z(Check if configure has been regenerated.zconfigure.acZ	configurer�noz
not neededNr)r>rrr	�regenerated_configure�srazpyconfig.h.in regeneratedcCs(d|kr d|krdSdSdSdS)z,Check if pyconfig.h.in has been regenerated.zconfigure.acz
pyconfig.h.inrr`z
not neededNr)r>rrr	�regenerated_pyconfig_h_in�srbcCst�}dd�|D�}dd�|D�}dd�|D�}tjjdd�tjjdd�ht|�@}t|�t|�t|�t|�t	|�t
|�t|�t|�|s�|r�|r�dnd	}t
�t
d
|�ndS)NcSs%g|]}|jd�r|�qS)z.py)rA)r+�fnrrr	r,�s	zmain.<locals>.<listcomp>cSs%g|]}|jd�r|�qS)�.c�.h)rdre)rA)r+rcrrr	r,�s	cSs4g|]*}|jd�r|jd�r|�qS)ZDoc�.rst�.inc)rfrg)�
startswithrA)r+rcrrr	r,�s	r[r\r^z and check for refleaks?�?zDid you run the test suite)r<r/r0r2r4rDrNrXrZr]r_rarbr)r>Zpython_filesZc_filesZ	doc_filesZ
misc_files�endrrr	�main�s$	'








rk�__main__)�rer
rTZos.pathr/r�	sysconfigrBrK�get_config_varr3r
rr%r<r@rDrN�compilerPrXrZr]r_�strrarbrk�__name__rrrr	�<module>s4
		$$