%PDF- %PDF-
Direktori : /lib64/python2.7/lib2to3/ |
Current File : //lib64/python2.7/lib2to3/main.pyc |
� {fc @� 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"