Your IP : 216.73.216.85


Current Path : /opt/alt/python37/lib64/python3.7/Tools/scripts/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/Tools/scripts/__pycache__/patchcheck.cpython-37.opt-1.pyc

B

� fH&�@sdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ej
�ddd�ej
�ddd�ej
�ddd�ej
�dd	�ej
�dd
�gZe�
d�Zdd
�ZdFdd�Zdd�Zdd�Zeddd�d�dd��Zeddd�d�dGdd��Zdd �Zed!ed�d"d#��Zed$ed�d%d&��Ze�d'�Zed(ed�d)d*��Zed+d,d-�d.d/��Zed0d,d-�d1d2��Zed3d,d-�d4d5��Zed6d,ed7�d8d9��Zed:d,ed7�d;d<��Z d=d>�Z!d?d@�Z"e#dAk�r�ddl$Z$e$j%edB�Z&e&j'dCdDdE�e&�(�Z)e)j!�r�e!e)j!�ne"�dS)Hz)Check proposed changes for common issues.�NZModulesZ_ctypesZ
libffi_osxZlibffi_msvcZ_decimalZlibmpdecZexpat�zlibZsrcdircCsd�||dkrdnd�S)z7Return 'N file(s)' with the proper plurality on 'file'.z	{} file{}��s�)�format)�count�r�=/opt/alt/python37/lib64/python3.7/Tools/scripts/patchcheck.py�n_files_strsr
Fcs���fdd�}|S)z*Decorator to output status info to stdout.cs����fdd�}|S)Ncs\tj��d�tj���||�}�s6�s6td�n"�rHt�|��nt|rRdnd�|S)Nz ... Zdone�yesZNO)�sys�stdout�write�flush�print)�args�kwargs�result)�fxn�info�message�modalrr	�call_fxn s


z/status.<locals>.decorated_fxn.<locals>.call_fxnr)rr)rrr)rr	�
decorated_fxnszstatus.<locals>.decorated_fxnr)rrrrr)rrrr	�statuss
rcCs6d��}ytj|tjtd�Stjk
r0dSXdS)z0Get the symbolic name for the current git branchzgit rev-parse --abbrev-ref HEAD)�stderr�cwdN)�split�
subprocess�check_output�DEVNULL�SRCDIR�CalledProcessError)�cmdrrr	�get_git_branch/sr$cCs:d��}ytj|tjtd�Wntjk
r4dSXdS)zkGet the remote name to use for upstream branches

    Uses "upstream" if it exists, "origin" otherwise
    zgit remote get-url upstream)rr�originZupstream)rrrr r!r")r#rrr	�get_git_upstream_remote:sr&zGetting base branch for PRcCs|dk	r|SdS)Nznot a PR branchr)�xrrr	�<lambda>J�r()rcCsftj�tj�td��sdStj}|jdkr0d}n
d�|�}t	�}|dksP||krTdSt
�}|d|S)Nz.gitZalphaZmasterz{0.major}.{0.minor}�/)�os�path�exists�joinr!r�version_info�releaselevelrr$r&)�version�base_branchZthis_branchZupstream_remoterrr	�get_base_branchIs

r3z6Getting the list of files that have been added/changedcCstt|��S)N)r
�len)r'rrr	r(]r)c	stj�tj�td��r�|r$d|}nd}g}tj|��tjtd��l}xd|j	D]Z}|�
���}|jdd�\}�t|�}|�
d�s�qLd�kr���dd	�d���|���qLWWd
QRXn
t�d�g}x:|D]2�tj����t�fdd
�tD��r�q�|���q�W|S)z0Get the list of changed or added files from git.z.gitzgit diff --name-status zgit status --porcelain)r
rr)�maxsplitZMAUz -> �Nz)need a git checkout to get modified filesc3s|]}��|�VqdS)N)�
startswith)�.0r,)�filenamerr	�	<genexpr>~sz changed_files.<locals>.<genexpr>)r+r,r-r.r!r�Popenr�PIPEr
�decode�rstrip�set�intersection�strip�appendr�exit�normpath�any�EXCLUDE_DIRS)r2r#�	filenames�st�lineZstatus_textrZ
filenames2r)r9r	�
changed_files\s2





rJcCsTt|�}|dkrt|�Sd�t|��g}x|D]}|�d�|��q.Wd�|�SdS)Nrz{}:z  {}�
)r4r
rrBr.)�
file_pathsr�linesr,rrr	�report_modified_files�s
rNzFixing Python file whitespacecCsdt_dd�|D�}|S)zAMake sure that the whitespace for .py files have been normalized.FcSs.g|]&}|�d�rt�tj�t|��r|�qS)z.py)�endswith�reindentZcheckr+r,r.r!)r8r,rrr	�
<listcomp>�sz(normalize_whitespace.<locals>.<listcomp>)rPZ
makebackup)rL�fixedrrr	�normalize_whitespace�srSzFixing C file whitespacec
Csbg}xX|D]P}tj�t|�}t|d��}d|��kr6w
WdQRXtj|ddd�|�|�q
W|S)zReport if any C files �r�	N�F)�verbose)	r+r,r.r!�open�read�untabifyZprocessrB)rLrRr,�abspath�frrr	�normalize_c_whitespace�s
r]s\s+(\r?\n)$zFixing docs whitespacecCs�g}x�|D]�}tj�t|�}yrt|d��}|��}WdQRXdd�|D�}||kr�t�||d�t|d��}|�|�WdQRX|�	|�Wq
t
k
r�}ztd||f�Wdd}~XYq
Xq
W|S)N�rbcSsg|]}t�d|��qS)s\1)�ws_re�sub)r8rIrrr	rQ�sz-normalize_docs_whitespace.<locals>.<listcomp>z.bak�wbzCannot fix %s: %s)r+r,r.r!rX�	readlines�shutilZcopyfile�
writelinesrB�	Exceptionr)rLrRr,r[r\rMZ	new_lines�errrrr	�normalize_docs_whitespace�s
&rgz
Docs modifiedT)rcCst|�S)z9Report if any file in the Doc directory has been changed.)�bool)rLrrr	�
docs_modified�srizMisc/ACKS updatedcCstj�dd�|kS)z$Check if Misc/ACKS has been changed.�MiscZACKS)r+r,r.)rLrrr	�credit_given�srkz Misc/NEWS.d updated with `blurb`cCstdd�|D��S)z&Check if Misc/NEWS.d has been changed.css$|]}|�tj�ddd��VqdS)rjzNEWS.d�nextN)r7r+r,r.)r8�prrr	r:�sz reported_news.<locals>.<genexpr>)rE)rLrrr	�
reported_news�srnzconfigure regenerated)rrcCs d|krd|krdSdSdSdS)z(Check if configure has been regenerated.zconfigure.acZ	configurer�noz
not neededNr)rLrrr	�regenerated_configure�srpzpyconfig.h.in regeneratedcCs d|krd|krdSdSdSdS)z,Check if pyconfig.h.in has been regenerated.zconfigure.acz
pyconfig.h.inrroz
not neededNr)rLrrr	�regenerated_pyconfig_h_in�srqcCs�|dkrtd�dSt�}t|�}dd�|D�}dd�|D�}dd�|D�}g}|�t|��|�t|��|�t|��|s�td�n&tdt|��d	��td
�t�	d�dS)NZfalsezNot a pull request; skippingcSsg|]}|�d�r|�qS)z.py)rO)r8�fnrrr	rQ�sztravis.<locals>.<listcomp>cSsg|]}|�d�r|�qS))z.cz.h)rO)r8rrrrr	rQ�scSs$g|]}|�d�r|�d�r|�qS)�Doc)z.rstz.inc)r7rO)r8rrrrr	rQ�szNo whitespace issues foundzPlease fix the z file(s) with whitespace issuesz9(on UNIX you can run `make patchcheck` to make the fixes)r)
rr3rJ�extendrSr]rgr4rrC)Zpull_requestr2rL�python_files�c_files�	doc_filesrRrrr	�travis�s"
rxcCs�t�}t|�}dd�|D�}dd�|D�}dd�|D�}dd�|D�}t|�t|�t|�t|�t|�t|�t|�t	|�|s�|r�|r�dnd}t
�t
d	|�dS)
NcSsg|]}|�d�r|�qS)z.py)rO)r8rrrrr	rQ�szmain.<locals>.<listcomp>cSsg|]}|�d�r|�qS))z.cz.h)rO)r8rrrrr	rQ�scSs$g|]}|�d�r|�d�r|�qS)rs)z.rstz.inc)r7rO)r8rrrrr	rQ�scSsh|]}|�d�r|�qS)rj)r7)r8rmrrr	�	<setcomp>�szmain.<locals>.<setcomp>z and check for refleaks?�?zDid you run the test suite)r3rJrSr]rgrirkrnrprqr)r2rLrurvrwZ
misc_files�endrrr	�main�s$r|�__main__)Zdescriptionz--traviszPerform pass/fail checks)�help)FN)N)*�__doc__�rerrcZos.pathr+rZ	sysconfigrPrZr,r.rFZget_config_varr!r
rr$r&r3rJrNrSr]�compiler_rgrirkrn�strrprqrxr|�__name__�argparse�ArgumentParser�parser�add_argument�
parse_argsrrrrr	�<module>sX


(