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

�
e f�B�@s�dZdZdZddlZddlZddlZiZd,ed<ed<d-ed<ed	<d.ed<d/ed
<ded<ed<ed
<ed<ed<fed<d0ZGdd�d�Zej	ej
eeedd�Zej	ej
eeedd�Zej	ej
eeedd�Z
eeedd�Zeeedd�Zeeedd�Zdd�Zeeed d!�Zeeed"d#�Zeeed$d%�Zd&e�Zd'd(�Zd)d*�Zed+kr�e�ndS)1�F�N�elif�else�end�if�while�for�except�finally�try�with�def�classc@s�eZdZejejeeedd�Z	dd�Z
dd�Zdd�Zd	d
�Z
dd�Zd
d�Zdd�Zdd�ZdS)�PythonIndentercCs|||_||_||_||_d|_||_|j|_tj	d�|_
tj	d�|_tj	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)�selfrrrrr�r�:/opt/alt/python34/lib64/python3.4/Tools/scripts/pindent.py�__init__ds						zPythonIndenter.__init__cCs6|jr%|j|j|j��n
|j|�dS)N)rrr)r�linerrrrxs	zPythonIndenter.writecCs+|jj�}|r'|jd7_n|S)N�)r�readliner)rr!rrrr#�szPythonIndenter.readlinecGsE|r||}ntjjd|j|f�|jd|�dS)NzError at line %d: %s
z### %s ###
)�sys�stderrrr)rZfmt�argsrrr�error�s
zPythonIndenter.errorcCsM|j�}x:|dd�dkrH|j�}|s;Pn||7}qW|S)N�z\
���)r#)rr!Zline2rrr�getline�szPythonIndenter.getlinecCs�t||j|j�\}}|jj|�j�}||d�}|dd�dkrvd|d||}n|j|�dS)Nr"�
�
��	� )r+r,r-)�divmodrrr�matchrr)rr!�indentZtabsZspaces�irrr�putline�szPythonIndenter.putlinecCs�g}xl|j�}|sPn|jj|�}|r�d}|jd�}|sb|jd�n&|j�d|kr�|jd�n|j|t|��q	n|jj|�}|r[|jd�}|t	kr|j|t|��|j
||f�q	n|tkr[|r[|j|t|�d�|d	\}}||f|d
<q	q[n|j|t|��q	W|r�|jd�x(|D]\}}|jd|�q�WndS)Nr�kwzunexpected endrz
unmatched endr"zunterminated keywordsz	%s
���r6)
r*rr1�groupr'�popr4�lenr�start�append�nextr)r�stackr!�mr5Zkw2ZkwaZkwbrrr�reformat�s@	
zPythonIndenter.reformatcCs�d}d}x�|j�}|s%Pn|jj|�}|rM|d7}qn|jj|�}|r�|jd�}|tkr�|d7}q�n|j|�qW||dkr�tjjd�n#||dkr�tjjd�ndS)Nrr"r5z5Warning: input contained more end tags than expected
z5Warning: input contained less end tags than expected
)	r*rr1rr7r:rr$r%)rZ
begin_counterZend_counterr!r>r5rrr�delete�s(
zPythonIndenter.deletecCs\g}g}d}}}}}x3|j�}|jj|�j�}	|jj|�}
|
r�d}|
jd�}|
jd�}n�|jj|�}
|
r�|
jd�}|tkr�d}n|d
kr�|
jd�}qd}n3||	|	d�dkr|j|�q%nd}|d|	�}
t	|
j
|j��}t	|j
|j��}x�||kr�|r�|r�d
||f}n
d|}|j||�d}}n|j
�\}}}}t	|j
|j��}qaW||kr�|r�|dkr/||kr"|jd�nd}}q�|sB|tkr�|r[d
||f}n
d|}|j||�d}}}q�n||kr�|j||||f�|r�|tkr�d}n|
|||f\}}}}n|r|tkr|}}|}q|}nx|D]}|j|�q Wg}|sGPn|j|�q%WdS)Nr-rr5�idr
rr"r+�#z# end %s %s
z	# end %s
zmismatched end)zdefzclass)r+rB)r*rr1rrr7rr<r;r9rrrr8r'r:)rr=ZtodoZ	currentwsZthisidZfirstkwZlastkwZtopidr!r3r>ZthiskwZendkwZindentwsr2Zcurrent�s�lrrr�complete�s�		




	!
		
zPythonIndenter.completeN)�__name__�
__module__�__qualname__r$�stdin�stdout�STEPSIZE�TABSIZE�
EXPANDTABSr rr#r'r*r4r?r@rErrrrrbs
+rcCs&t|||||�}|j�dS)N)rrE)�input�output�stepsizerr�pirrr�complete_filterKsrRcCs&t|||||�}|j�dS)N)rr@)rNrOrPrrrQrrr�
delete_filterQsrScCs&t|||||�}|j�dS)N)rr?)rNrOrPrrrQrrr�reformat_filterWsrTcCsGtj|�}tj�}t|||||�}|j�|j�S)N)�io�StringIOrrE�getvalue)�sourcerPrrrNrOrQrrr�complete_string]s

rYcCsGtj|�}tj�}t|||||�}|j�|j�S)N)rUrVrr@rW)rXrPrrrNrOrQrrr�
delete_stringes

rZcCsGtj|�}tj�}t|||||�}|j�|j�S)N)rUrVrr?rW)rXrPrrrNrOrQrrr�reformat_stringms

r[cCs�ddl}ddl}|d}|jj|�rwy|j|�Wqwtk
rstd|fdtj�YqwXny|j	||�Wn/tk
r�td||fdtj�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

"
rfcCs|t|d��}|j�}WdQXt||||�}||krIdSt|�t|d��}|j|�WdQXdS)N�rr�wr")�open�readrYrfr)rerPrr�frX�resultrrr�
complete_file�s
rmcCs|t|d��}|j�}WdQXt||||�}||krIdSt|�t|d��}|j|�WdQXdS)Nrgrrhr")rirjrZrfr)rerPrrrkrXrlrrr�delete_file�s
rncCs|t|d��}|j�}WdQXt||||�}||krIdSt|�t|d��}|j|�WdQXdS)Nrgrrhr")rirjr[rfr)rerPrrrkrXrlrrr�
reformat_file�s
roaG
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).
cCsEtjjd|d|dd�tjjt�tjd�dS)Nz Error: You can not specify both z and -rz at the same time
r()r$r%r�usage�exit)Zop1Zop2rrr�
error_both�s$rrcCs?ddl}y)|jtjdd�d�\}}WnY|jk
r�}z6tjjd|�tjjt�tjd�WYdd}~XnXd}t}t	}t
}x�|D]�\}}	|dkr�|r�t||�nd}q�|dkr|r	t||�nd	}q�|d
kr=|r4t||�nd}q�|dkrXt|	�}q�|d
krst|	�}q�|dkr�d}q�q�W|s�tjjd�tjjt�tjd�n|s�|dgkrt
|d�}|tjtj|||�n4t
|d�}x!|D]}
||
|||�qWdS)Nrr"zcdrs:t:ez
Error: %s
r(z-crEz-dr@z-rr?z-sz-tz-eTz7You must specify -c(omplete), -d(elete) or -r(eformat)
�-Z_filterZ_file)�getoptr$�argvr'r%rrprqrKrLrMrr�int�evalrIrJ)rtZoptsr&�msg�actionrPrr�o�arerrr�test�sR) 			
	
r|�__main__)zelif�else�end)r~r)�except�finally)r�r~r�r)zifzwhilezforztryzwithzdefzclass)rKrLrMrUrr$r<r:rrIrJrRrSrTrYrZr[rfrmrnro�varsrprrr|rFrrrr�<module>Ps@

*
�
3