관리-도구
편집 파일: main.cpython-33.pyc
� ��fh- c @ 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 d � Z Gd d � d e j � Z d d � Z d d d � Z d S( u Main program for 2to3. i ( u with_statementNi ( u refactorc C s: | j � } | j � } t j | | | | d d d d �S( u% Return a unified diff of two strings.u (original)u (refactored)u linetermu ( u splitlinesu difflibu unified_diff( u au bu filename( ( u1 /opt/alt/python33/lib64/python3.3/lib2to3/main.pyu diff_texts s u diff_textsc s_ | Ee Z d Z d Z d d d � f d d � Z d d � Z � f d d � Z d d � Z � S( u StdoutRefactoringToolu2 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. u c sv | | _ | | _ | r; | j t j � r; | t j 7} n | | _ | | _ | | _ t t | � j | | | � d S( uF 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( u nobackupsu show_diffsu endswithu osu sepu _input_base_diru _output_diru _append_suffixu superu StdoutRefactoringToolu __init__( u selfu fixersu optionsu explicitu nobackupsu show_diffsu input_base_diru output_diru append_suffix( u __class__( u1 /opt/alt/python33/lib64/python3.3/lib2to3/main.pyu __init__$ s u StdoutRefactoringTool.__init__c O s3 | j j | | | f � | j j | | | � d S( N( u errorsu appendu loggeru error( u selfu msgu argsu kwargs( ( u1 /opt/alt/python33/lib64/python3.3/lib2to3/main.pyu log_errorA s u StdoutRefactoringTool.log_errorc ! s | } | j rk | j | j � rO t j j | j | t | j � d � � } qk 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 s�| d } t j j | � rNy t j | � WqNt j k rJ} z | j d | � WYd d } ~ XqNXn y t j | | � Wq�t j k r�} z | j d | | � WYd d } ~ Xq�Xn t t | � j } | | | | | � | j s�t j | | � n | | k rt j | | � n d S( Nu5 filename %s does not start with the input_base_dir %su Writing converted %s to %s.u .baku Can't remove backup %su Can't rename %s to %s( u _output_diru startswithu _input_base_diru osu pathu joinu lenu ValueErroru _append_suffixu dirnameu isdiru makedirsu log_messageu nobackupsu lexistsu removeu erroru renameu superu StdoutRefactoringToolu write_fileu shutilu copymode( u selfu new_textu filenameu old_textu encodingu orig_filenameu output_diru backupu erru write( u __class__( u1 /opt/alt/python33/lib64/python3.3/lib2to3/main.pyu write_fileE s@ &) u StdoutRefactoringTool.write_filec C s� | r | j d | � n� | j d | � | j r� t | | | � } yi | j d k r� | j �- x | D] } t | � qg Wt j j � Wd QXn x | D] } t | � q� WWq� t k r� t d | f � d SYq� Xn d S( Nu No changes to %su Refactored %su+ couldn't encode %s's diff for your terminal( u log_messageu show_diffsu diff_textsu output_locku Noneu printu sysu stdoutu flushu UnicodeEncodeErroru warn( u selfu oldu newu filenameu equalu diff_linesu line( ( u1 /opt/alt/python33/lib64/python3.3/lib2to3/main.pyu print_outputl s"