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__/pindent.cpython-37.pyc

B

� f�B�@sxdZdZdZddlZddlZddlZiZded<ed<ded<ed	<d
ed<ded
<ded<ed<ed<ed<ed<ded<dZGdd�d�Zej	ej
eeefdd�Zej	ej
eeefdd�Zej	ej
eeefdd�Z
eeefdd�Zeeefd d!�Zeeefd"d#�Zd$d%�Zeeefd&d'�Zeeefd(d)�Zeeefd*d+�Zd,e�Zd-d.�Zd/d0�Zed1k�rte�dS)2�F�N)�elif�else�end�ifr)rr�while�for)�except�finally�try)r	rr
rr	rrr
�with�def�class�)rrrrrr
rc@sdeZdZejejeeefdd�Z	dd�Z
dd�Zdd�Zd	d
�Z
dd�Zd
d�Zdd�Zdd�ZdS)�PythonIndentercCsT||_||_||_||_d|_||_|j|_t�	d�|_
t�	d�|_t�	d�|_dS)NrzC^(?:\s|\\\n)*(?P<kw>[a-z]+)((?:\s|\\\n)+(?P<id>[a-zA-Z_]\w*))?[^\w]zE^(?:\s|\\\n)*#?\s*end\s+(?P<kw>[a-z]+)(\s+(?P<id>[a-zA-Z_]\w*))?[^\w]z^[ \t]*)
�fpi�fpo�
indentsize�tabsize�lineno�
expandtabs�write�_write�re�compile�kwprog�endprog�wsprog)�selfrrrrrrr�:/opt/alt/python37/lib64/python3.7/Tools/scripts/pindent.py�__init__dszPythonIndenter.__init__cCs(|jr|�|�|j��n
|�|�dS)N)rrr)r�linerrrrxszPythonIndenter.writecCs |j��}|r|jd7_|S)N�)r�readliner)rr!rrrr#�s
zPythonIndenter.readlinecGs4|r||}tj�d|j|f�|�d|�dS)NzError at line %d: %s
z### %s ###
)�sys�stderrrr)rZfmt�argsrrr�error�szPythonIndenter.errorcCs8|��}x*|dd�dkr2|��}|s(P||7}q
W|S)N���z\
)r#)rr!Zline2rrr�getline�szPythonIndenter.getlinecCsdt||j|j�\}}|j�|���}||d�}|dd�dkrVd|d||}|�|�dS)Nr")�
�
��	� )�divmodrrr�matchrr)rr!�indentZtabsZspaces�irrr�putline�szPythonIndenter.putlinecCs4g}x�|��}|sP|j�|�}|rnd}|�d�}|sB|�d�n|��d|kr\|�d�|�|t|��q|j�|�}|r�|�d�}|t	kr�|�|t|��|�
||f�q|tkr�|r�|�|t|�d�|d\}}||f|d<q|�|t|��qW|�r0|�d�x |D]\}}|�d	|��qWdS)
Nr�kwzunexpected endrz
unmatched endr"���zunterminated keywordsz	%s
)
r)rr0�groupr'�popr3�lenr�start�append�nextr)r�stackr!�mr4Zkw2ZkwaZkwbrrr�reformat�s@



zPythonIndenter.reformatcCs�d}d}x`|��}|sP|j�|�}|r2|d7}q
|j�|�}|r\|�d�}|tkr\|d7}|�|�q
W||dkr�tj�d�n||dkr�tj�d�dS)Nrr"r4z5Warning: input contained more end tags than expected
z5Warning: input contained less end tags than expected
)	r)rr0rr6r9rr$r%)rZ
begin_counterZend_counterr!r=r4rrr�delete�s(
zPythonIndenter.deletecCsxg}g}d}}}}}�xT|��}|j�|���}	|j�|�}
|
rbd}|
�d�}|
�d�}nf|j�|�}
|
r�|
�d�}|tkr�d}|dkr�|
�d�}q�d}n&||	|	d�dkr�|�|�q nd}|d|	�}
t	|
�
|j��}t	|�
|j��}xf||k�rZ|�r8|�rd||f}nd	|}|�||�d}}|�
�\}}}}t	|�
|j��}q�W||k�r�|�r�|dk�r�||k�r�|�d
�d}}nF|�r�|tk�r�|�r�d||f}nd	|}|�||�d}}}||k�r|�||||f�|�r
|tk�r
d}|
|||f\}}}}|�r@|tk�r<|}}|}n|}x|D]}|�|��qFWg}|�sfP|�|�q WdS)Nr,rr4�id)r
rr")r*�#z# end %s %s
z	# end %s
zmismatched end)r)rr0rrr6rr;r:r8rrrr7r'r9)rr<ZtodoZ	currentwsZthisidZfirstkwZlastkwZtopidr!r2r=ZthiskwZendkwZindentwsr1Zcurrent�s�lrrr�complete�s�









zPythonIndenter.completeN)�__name__�
__module__�__qualname__r$�stdin�stdout�STEPSIZE�TABSIZE�
EXPANDTABSr rr#r'r)r3r>r?rDrrrrrbs
+rcCst|||||�}|��dS)N)rrD)�input�output�stepsizerr�pirrr�complete_filterKsrQcCst|||||�}|��dS)N)rr?)rMrNrOrrrPrrr�
delete_filterQsrRcCst|||||�}|��dS)N)rr>)rMrNrOrrrPrrr�reformat_filterWsrScCs2t�|�}t��}t|||||�}|��|��S)N)�io�StringIOrrD�getvalue)�sourcerOrrrMrNrPrrr�complete_string]s

rXcCs2t�|�}t��}t|||||�}|��|��S)N)rTrUrr?rV)rWrOrrrMrNrPrrr�
delete_stringes

rYcCs2t�|�}t��}t|||||�}|��|��S)N)rTrUrr>rV)rWrOrrrMrNrPrrr�reformat_stringms

rZcCs�ddl}ddl}|d}|j�|�r\y|�|�Wn(tk
rZtd|ftjd�YnXy|�	||�Wn*tk
r�td||ftjd�YnXdS)Nr�~zCan't remove backup %r)�filezCan't rename %r to %r)
�osZos.path�path�lexists�remove�OSError�printr$r%�rename)�filenamer]Zbackuprrr�make_backupusrec	Csdt|d��}|��}WdQRXt||||�}||kr8dSt|�t|d��}|�|�WdQRXdS)N�rr�wr")�open�readrXrer)rdrOrr�frW�resultrrr�
complete_file�srlc	Csdt|d��}|��}WdQRXt||||�}||kr8dSt|�t|d��}|�|�WdQRXdS)Nrfrrgr")rhrirYrer)rdrOrrrjrWrkrrr�delete_file�srmc	Csdt|d��}|��}WdQRXt||||�}||kr8dSt|�t|d��}|�|�WdQRXdS)Nrfrrgr")rhrirZrer)rdrOrrrjrWrkrrr�
reformat_file�srnaG
usage: pindent (-c|-d|-r) [-s stepsize] [-t tabsize] [-e] [file] ...
-c         : complete a correctly indented program (add #end directives)
-d         : delete #end directives
-r         : reformat a completed program (use #end directives)
-s stepsize: indentation step (default %(STEPSIZE)d)
-t tabsize : the worth in spaces of a tab (default %(TABSIZE)d)
-e         : expand TABs into spaces (default OFF)
[file] ... : files are changed in place, with backups in file~
If no files are specified or a single - is given,
the program acts as a filter (reads stdin, writes stdout).
cCs:tj�d|d|dd�tj�t�t�d�dS)Nz Error: You can not specify both z and -rz at the same time
�)r$r%r�usage�exit)Zop1Zop2rrr�
error_both�s rrc
Cs�ddl}y|�tjdd�d�\}}WnJ|jk
rp}z*tj�d|�tj�t�t�d�Wdd}~XYnXd}t}t	}t
}x�|D]�\}}	|dkr�|r�t||�d}q�|dkr�|r�t||�d	}q�|d
kr�|r�t||�d}q�|dkr�t|	�}q�|d
k�r
t|	�}q�|dkr�d}q�W|�sBtj�d�tj�t�t�d�|�rT|dgk�rvt
|d�}|tjtj|||�n*t
|d�}x|D]}
||
|||��q�WdS)Nrr"zcdrs:t:ez
Error: %s
roz-crDz-dr?z-rr>z-sz-tz-eTz7You must specify -c(omplete), -d(elete) or -r(eformat)
�-Z_filterZ_file)�getoptr$�argvr'r%rrprqrJrKrLrr�int�evalrHrI)rtZoptsr&�msg�actionrOrr�o�ardrrr�test�sR







r|�__main__)rJrKrLrTrr$r;r9rrHrIrQrRrSrXrYrZrerlrmrn�varsrprrr|rErrrr�<module>PsB(j
3