Your IP : 3.144.224.105


Current Path : /lib64/python2.7/Tools/scripts/
Upload File :
Current File : //lib64/python2.7/Tools/scripts/cleanfuture.pyo

�
�fc@s�dZddlZddlZddlZddlZdadadad�Zd�Z	d�Z
dd
d��YZed	kr�e	�ndS(s�cleanfuture [-d][-r][-v] path ...

-d  Dry run.  Analyze, but don't make any changes to, files.
-r  Recurse.  Search for all .py files in subdirectories too.
-v  Verbose.  Print informative msgs.

Search Python (.py) files for future statements, and remove the features
from such statements that are already mandatory in the version of Python
you're using.

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.

Overwrites files in place, renaming the originals with a .bak extension. If
cleanfuture finds nothing to change, the file is left alone.  If cleanfuture
does change a file, the changed file is a fixed-point (i.e., running
cleanfuture on the resulting .py file won't change it again, at least not
until you try it again with a later Python release).

Limitations:  You can do these things, but this tool won't help you then:

+ A future statement cannot be mixed with any other statement on the same
  physical line (separated by semicolon).

+ A future statement cannot contain an "as" clause.

Example:  Assuming you're using Python 2.2, if a file containing

from __future__ import nested_scopes, generators

is analyzed by cleanfuture, the line is rewritten to

from __future__ import generators

because nested_scopes is no longer optional in 2.2 but generators is.
i����NicGsOtt|�}dj|�}|ddkr;|d7}ntjj|�dS(Nt i����s
(tmaptstrtjointsyststderrtwrite(targststringstmsg((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pyterrprint2s

cCs�ddl}y#|jtjdd�\}}Wn!|jk
rR}t|�dSXx_|D]W\}}|dkrtd7aqZ|dkr�td7aqZ|dkrZtd7aqZqZW|s�tdt�dSx|D]}t	|�q�WdS(Ni����itdrvs-ds-rs-vsUsage:(
tgetoptRtargvterrorR
tdryruntrecursetverboset__doc__tcheck(RtoptsRR	totatarg((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pytmain9s$#




cCs�tjj|�r�tjj|�r�tr7dG|GHntj|�}xp|D]h}tjj||�}tr�tjj|�r�tjj|�s�|j�j	d�rMt
|�qMqMWdStr�dG|GdGnyt|�}Wn.tk
r}t
d|t|�f�dSXt||�}|j�}|rA|j�n|j�|r�trmdGHtrmdGHqmnxw|D]o\}}	}
d||d	|	d	fGHx&t||	d	�D]}|j|Gq�W|
dkr�d
GHqtdGH|
GqtWts�|d}tjj|�rtj|�ntj||�trCd
G|GdG|GHnt|d�}
|j|
�|
j�tr~dG|GHq~q�ntr�dGHndS(Nslisting directorys.pytcheckings...s%r: I/O Error: %sschanged.s+But this is a dry run, so leaving it alone.s%r lines %d-%dis
-- deleteds
-- change to:s.baktrenamedttotws	wrote news
unchanged.(tostpathtisdirtislinkRtlistdirRRtlowertendswithRtopentIOErrorR
RtFutureFindertrunt
gettheresttcloseRtrangetlinestNonetexiststremovetrenameR(tfiletnamestnametfullnametfR	tfftchangedtstetlinetitbaktg((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pyRNsd%





R&cBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs1||_||_d|_g|_g|_dS(Ni(R4tfnametateofR+R6(tselfR4R=((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pyt__init__�s
				cCsH|jr
dS|jj�}|dkr4d|_n|jj|�|S(Nti(R>R4treadlineR+tappend(R?R9((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pytgetline�s	cCs	tj}tj}tj}tj}tj}tj}|j}tj|j	�j
}|�\}	}
\}}\}
}}x=|	|||fkr�|�\}	}
\}}\}
}}q{Wx4|	|kr�|�\}	}
\}}\}
}}q�Wxx=|	|||fkr1|�\}	}
\}}\}
}}q�W|	|koG|
dksNPn|d}|�\}	}
\}}\}
}}|	|ko�|
dks�Pn|�\}	}
\}}\}
}}|	|ko�|
dks�Pn|�\}	}
\}}\}
}}g}x�|	|kr�|j|
�|�\}	}
\}}\}
}}|	|koW|
dks^Pn|�\}	}
\}}\}
}}qWd}|	|kr�|
}|�\}	}
\}}\}
}}n|	|k	r�t
d|j||f�gS|d}g}xs|D]k}tt|d�}|dkr:|j|�q|j�}|dksq|tjkrdq|j|�qWt|�t|�kr�t|�dkr�d}n@d}|d	j|�7}|dk	r�|d
|7}n|d7}|j|||f�q�q�W|S(Ntfromit
__future__timportt,s)Skipping file %r; can't parse line %d:
%sisfrom __future__ import s, Rs
(ttokenizetSTRINGtNLtNEWLINEtCOMMENTtNAMEtOPR6tgenerate_tokensRDtnextRCR,R
R=tgetattrRFtgetMandatoryReleaseRtversion_infotlenR(R?RJRKRLRMRNROR6tgetttypettokentsrowtscolterowtecolR9t	startlinetfeaturestcommenttendlinet
okfeaturesR4tobjecttreleased((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pyR'�sz							$(((
$$$
$('

	
cCs+|jrd|_n|jj�|_dS(NRA(R>ttherestR4tread(R?((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pyR(�s	cCs�|j}g|_|j�xN|D]F\}}}|dkrR|j||d5q#|g|j||d+q#W|j|j�|jr�|j|j�ndS(Ni(R6treverseR,R+t
writelinesRdR(R?R4R6R7R8R9((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pyRs		
	(t__name__t
__module__R@RDR'R(R(((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pyR&�s
	
	
	_	t__main__((
RRFRIRRRRRR
RRR&Rh(((s1/usr/lib64/python2.7/Tools/scripts/cleanfuture.pyt<module>'s			8�

?>