Your IP : 216.73.216.213


Current Path : /opt/alt/python33/lib64/python3.3/Tools/scripts/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/Tools/scripts/__pycache__/reindent.cpython-33.pyo

�
��f
-c@s�dZdZddlZddlZddlZddlZdadada	dada
ddd�Zdd�Zdd	�Zd
d�Zdd
d�ZGdd�d�Zdd�Zedkr�e�ndS(u�reindent [-d][-r][-v] [ path ... ]

-d (--dryrun)   Dry run.   Analyze, but don't make any changes to, files.
-r (--recurse)  Recurse.   Search for all .py files in subdirectories too.
-n (--nobackup) No backup. Does not make a ".bak" file before reindenting.
-v (--verbose)  Verbose.   Print informative msgs; else no output.
   (--newline)  Newline.   Specify the newline character to use (CRLF, LF).
                           Default is the same as the original file.
-h (--help)     Help.      Print this usage information and exit.

Change Python (.py) files to use 4-space indents and no hard tab characters.
Also trim excess spaces and tabs from ends of lines, and remove empty lines
at the end of files.  Also ensure the last line ends with a newline.

If no paths are given on the command line, reindent operates as a filter,
reading a single source file from standard input and writing the transformed
source to standard output.  In this case, the -d, -r and -v flags are
ignored.

You can pass one or more file and/or directory paths.  When a directory
path, all .py files within the directory will be examined, and, if the -r
option is given, likewise recursively for subdirectories.

If output is not to standard output, reindent overwrites files in place,
renaming the originals with a .bak extension.  If it finds nothing to
change, the file is left alone.  If reindent does change a file, the changed
file is a fixed-point for future runs (i.e., running reindent on the
resulting .py file won't change it again).

The hard part of reindenting is figuring out what to do with comment
lines.  So long as the input files get a clean bill of health from
tabnanny.py, reindent should do a good job.

The backup file is a copy of the one that is being reindented. The ".bak"
file is generated with shutil.copy(), but some corner cases regarding
user/group and permissions could leave the backup file more readable than
you'd prefer. You can always use the --nobackup option to prevent this.
u1iNcCs,|dkrt}nt|dtj�dS(Nufile(uNoneu__doc__uprintusysustderr(umsg((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyuusage;s	uusagecGs:tjjdjdd�|D���tjjd�dS(Nu css|]}t|�VqdS(N(ustr(u.0uarg((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyu	<genexpr>Bsuerrprint.<locals>.<genexpr>u
(usysustderruwriteujoin(uargs((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyuerrprintAs&uerrprintcCs�ddl}y>|jtjdd�ddddddd	g�\}}Wn6|jk
r�}zt|�dSWYdd}~XnXx�|D]�\}}|dkr�daq�|dkr�daq�|dkr�da	q�|dkr�da
q�|dkr5|j�d krt�dStdddd�|j�a
q�|d!kr�t�dSq�W|s�ttj�}|j�|jtj�dSx|D]}t|�q�WdS("Niiudrnvhudryrunurecurseunobackupuverboseunewline=uhelpu-du--dryrunu-ru	--recurseu-nu
--nobackupu-vu	--verboseu	--newlineuCRLFuLFu
u
u-hu--help(u-du--dryrunT(u-ru	--recurse(u-nu
--nobackupF(u-vu	--verbose(u	--newline(uCRLFuLF(u-hu--help(ugetoptusysuargvuerroruusageuTrueudryrunurecurseuFalseu
makebackupuverboseuupperudictuspec_newlineu
Reindenterustdinurunuwriteustdoutucheck(ugetoptuoptsuargsumsguouauruarg((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyumainEs>%
				"

umaincCs�tjj|�r�tjj|�r�tr;td|�ntj|�}x�|D]�}tjj||�}tr�tjj|�r�tjj|�r�tjj	|�dj
d�s�|j�jd�rQt
|�qQqQWdStrtd|ddd�nt|d	��}tj|j�\}}WdQXy+t|d
|��}t|�}WdQXWnCtk
r�}z#td|t|�f�dSWYdd}~XnXtr�tn|j}	t|	t�r�td|�dS|j�r�tr	td
�tr	td�q	nts�|d}
trNtj||
�trNtd|d|
�qNnt|dd
|d|	��}|j|�WdQXtr�td|�q�ndStr�td�ndSdS(Nulisting directoryiu.u.pyucheckingu...uendu urbuencodingu%s: I/O Error: %su>%s: mixed newlines detected; cannot continue without --newlineuchanged.u+But this is a dry run, so leaving it alone.u.baku	backed uputouwunewlineu	wrote newu
unchanged.TF("uosupathuisdiruislinkuverboseuprintulistdirujoinurecurseusplitu
startswithuloweruendswithucheckuopenutokenizeudetect_encodingureadlineu
ReindenteruIOErroruerrprintustruspec_newlineunewlinesu
isinstanceutupleurunudryrunu
makebackupushutilucopyfileuwriteuTrueuFalse(ufileunamesunameufullnameufuencodingu_urumsgunewlineubak((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyucheckhsZ%
 


uchecku
 	cCsKt|�}x.|dkr<||d|kr<|d8}qW|d|�S(uReturn line stripped of trailing spaces, tabs, newlines.

    Note that line.rstrip() instead also strips sundry control characters,
    but at least one known Emacs user expects to keep junk like that, not
    mentioning Barry by name or anything <wink>.
    iiN(ulen(ulineuJUNKui((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyu_rstrip�s#u_rstripcBsn|EeZdZdd�Zdd�Zdd�Zdd�Zejej	ej
ejejd	d
�Z
dS(u
ReindentercCsod|_d|_|j�|_dd�|jD�|_|jjdd�d|_g|_|j	|_	dS(NiicSs&g|]}t|�j�d�qS(u
(u_rstripu
expandtabs(u.0uline((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyu
<listcomp>�s	u'Reindenter.__init__.<locals>.<listcomp>(
u	find_stmtulevelu	readlinesurawulinesuinsertuNoneuindexustatsunewlines(uselfuf((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyu__init__�s					uReindenter.__init__cCs*tj|j�}x|D]}|j|�qW|j}x$|r_|ddkr_|j�q<W|j}|jt|�df�i}g}|_	|dd}|j
|d|��x]tt|�d�D]E}||\}}	||dd}
t||�}|	d}|dkrH|r?|j
|d�}|dkr�xkt|dt|�d�D]I}
||
\}}|dkra|t||�kr�|d}nPqaqaWn|dkr'xgt|ddd	�D]L}
||
\}}|dkr�|t||d�t||�}Pq�q�Wn|dkrE|}qEqHd}n|||<||}|dkst|dkr�|j
|||
��q�x�|||
�D]s}|dkr�|dkr�|j|�q|jd||�q�tt|�|�}|j||d��q�Wq�W|j|j	kS(
Niu
iiu i����i����i����i����(utokenizeugenerate_tokensugetlineu
tokeneaterulinesupopustatsuappendulenuafteruextendurangeu	getlspaceugetuminuraw(uselfutokensu_tokenulinesustatsu	have2wantuafteruiuthisstmtu	thislevelunextstmtuhaveuwantujujlineujleveludiffulineuremove((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyurun�sb
		

$
	

uReindenter.runcCs|j|j�dS(N(u
writelinesuafter(uselfuf((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyuwritesuReindenter.writecCsD|jt|j�kr!d}n|j|j}|jd7_|S(Nui(uindexulenulines(uselfuline((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyugetlines
	uReindenter.getlinecCs�||krd|_n�||kr?d|_|jd7_n�||krfd|_|jd8_n||	kr�|jr�|jj|ddf�q�nJ||
kr�n;|jr�d|_|r�|jj|d|jf�q�ndS(Niii����(u	find_stmtulevelustatsuappend(uselfutypeutokenuslinecoluendulineuINDENTuDEDENTuNEWLINEuCOMMENTuNL((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyu
tokeneaters"			 		uReindenter.tokeneaterN(u__name__u
__module__u__qualname__u__init__urunuwriteugetlineutokenizeuINDENTuDEDENTuNEWLINEuCOMMENTuNLu
tokeneater(u
__locals__((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyu
Reindenter�sG
u
ReindentercCsDdt|�}}x*||kr?||dkr?|d7}qW|S(Niu i(ulen(ulineuiun((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyu	getlspaceAsu	getlspaceu__main__FT(u__doc__u__version__utokenizeuosushutilusysuFalseuverboseurecurseudryrunuTrueu
makebackupuNoneuspec_newlineuusageuerrprintumainuchecku_rstripu
Reindenteru	getlspaceu__name__(((u;/opt/alt/python33/lib64/python3.3/Tools/scripts/reindent.pyu<module>*s&#4�