/
/
usr/
lib64/
lib64/
/
lib64/
lib64/
/ó
ÛœSec @€ s© d Z d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m
Z
d „ Z d e
j f d „ ƒ YZ
d „ Z d d
„ Z d S( s
Main program for 2to3.
iÿÿÿÿ( t with_statementNi ( t refactorc C€ s: | j ƒ } | j ƒ } t j | | | | d d d d ƒS( s% Return a unified diff of two strings.s
(original)s (refactored)t linetermt ( t
splitlinest difflibt unified_diff( t at bt filename( ( s$ /usr/lib64/python2.7/lib2to3/main.pyt
diff_texts s
t StdoutRefactoringToolc B€ s; e Z d Z d d d d „ Z d „ Z d „ Z d „ Z RS( s2
A refactoring tool that can avoid overwriting its input files.
Prints output to stdout.
Output files can optionally be written to a different directory and or
have an extra file suffix appended to their name for use in situations
where you do not want to replace the input files.
R c C€ sv | | _ | | _ | r; | j t j ƒ r; | t j 7} n | | _ | | _ | | _ t t | ƒ j
| | | ƒ d S( sF
Args:
fixers: A list of fixers to import.
options: A dict with RefactoringTool configuration.
explicit: A list of fixers to run even if they are explicit.
nobackups: If true no backup '.bak' files will be created for those
files that are being refactored.
show_diffs: Should diffs of the refactoring be printed to stdout?
input_base_dir: The base directory for all input files. This class
will strip this path prefix off of filenames before substituting
it with output_dir. Only meaningful if output_dir is supplied.
All files processed by refactor() must start with this path.
output_dir: If supplied, all converted files will be written into
this directory tree instead of input_base_dir.
append_suffix: If supplied, all files output by this tool will have
this appended to their filename. Useful for changing .py to
.py3 for example by passing append_suffix='3'.
N( t nobackupst
show_diffst endswitht ost sept _input_base_dirt _output_dirt _append_suffixt superR t __init__( t selft fixerst optionst explicitR R
t input_base_dirt
output_dirt
append_suffix( ( s$ /usr/lib64/python2.7/lib2to3/main.pyR $ s c O€ s3 | j j | | | f ƒ | j j | | | Ž d S( N( t errorst appendt loggert error( R t msgt argst kwargs( ( s$ /usr/lib64/python2.7/lib2to3/main.pyt log_errorA s c
C€ sÝ | } | j re | j | j ƒ rI t j j | j | t | j ƒ ƒ } qe t d | | j f ƒ ‚ n | j r~ | | j 7} n | | k rÔ t j j | ƒ } t j j
| ƒ s¾ t j | ƒ n | j d | | ƒ n | j
sy| d } t j j | ƒ r6y t j | ƒ Wq6t j k
r2} | j d | ƒ q6Xn y t j | | ƒ Wqyt j k
ru} | j d | | ƒ qyXn t t | ƒ j } | | | | | ƒ | j
sºt j | | ƒ n | | k rÙt j | | ƒ n d S( Ns5 filename %s does not start with the input_base_dir %ss Writing converted %s to %s.s .baks Can't remove backup %ss Can't rename %s to %s( R t
startswithR R t patht joint lent
ValueErrorR t dirnamet isdirt makedirst log_messageR t lexistst removeR t renameR R t
write_filet shutilt copymode(
R t new_textR t old_textt encodingt
orig_filenameR t backupt errt write( ( s$ /usr/lib64/python2.7/lib2to3/main.pyR1 E s@
c C€ sÐ | r | j d | ƒ n³ | j d | ƒ | j rÌ t | | | ƒ } y_ | j d k rŒ | j ( x | D] } | GHqg Wt j j ƒ Wd QXn x | D] } | GHq“ WWqÌ t k
rÈ t d | f ƒ d SXn d S( Ns No changes to %ss
Refactored %ss+ couldn't encode %s's diff for your terminal(
R- R
R
t output_lockt Nonet syst stdoutt flusht UnicodeEncodeErrort warn( R t oldt newR t equalt
diff_linest line( ( s$ /usr/lib64/python2.7/lib2to3/main.pyt print_outputl s"
( t __name__t
__module__t __doc__R R$ R1 RG ( ( ( s$ /usr/lib64/python2.7/lib2to3/main.pyR s
'c C€ s t j d | f IJd S( Ns WARNING: %s( R= t stderr( R! ( ( s$ /usr/lib64/python2.7/lib2to3/main.pyRA ‚ s c € s„ t j d d ƒ } | j d d d d d d ƒ| j d d
d d d g d d
ƒ| j d d d d d d d d d d ƒ| j d d d d d g d d ƒ| j d d d d d d ƒ| j d d d d d d ƒ| j d d d d d d ƒ| j d! d d d d" ƒ| j d# d$ d d d d% ƒ| j d&