Ñò
$8Zc           @€  s©   d  Z  d d k l Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k	 l
 Z
 d „  Z d e
 i f d „  ƒ  YZ d	 „  Z d d
 „ Z d S(   s   
Main program for 2to3.
iÿÿÿÿ(   t   with_statementNi   (   t   refactorc      	   C€  s:   |  i  ƒ  }  | i  ƒ  } t i |  | | | 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/lib/python2.6/lib2to3/main.pyt
   diff_texts   s
    	t   StdoutRefactoringToolc           B€  s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s"   
    Prints output to stdout.
    c         C€  s2   | |  _  | |  _ t t |  ƒ i | | | ƒ d  S(   N(   t	   nobackupst
   show_diffst   superR   t   __init__(   t   selft   fixerst   optionst   explicitR   R   (    (    s"   /usr/lib/python2.6/lib2to3/main.pyR      s    		c         O€  s3   |  i  i | | | f ƒ |  i i | | | Ž d  S(   N(   t   errorst   appendt   loggert   error(   R   t   msgt   argst   kwargs(    (    s"   /usr/lib/python2.6/lib2to3/main.pyt	   log_error$   s    c         C€  sô   |  i  p£ | d } t i i | ƒ o@ y t i | ƒ Wqg t i j
 o } |  i d | ƒ qg Xn y t i | | ƒ Wq­ t i j
 o } |  i d | | ƒ q­ Xn t t	 |  ƒ i
 } | | | | | ƒ |  i  p t i | | ƒ n d  S(   Ns   .baks   Can't remove backup %ss   Can't rename %s to %s(   R   t   ost   patht   lexistst   removeR   t   log_messaget   renameR   R   t
   write_filet   shutilt   copymode(   R   t   new_textR	   t   old_textt   encodingt   backupt   errt   write(    (    s"   /usr/lib/python2.6/lib2to3/main.pyR"   (   s    


c      
   C€  sã   | o |  i  d | ƒ nÅ |  i  d | ƒ |  i oª t | | | ƒ } yl |  i d  j	 oB |  i i i ƒ  z' x | D] } | GHqv Wt i i	 ƒ  Wd  QXn x | D] } | GHq£ WWqß t
 j
 o t d | f ƒ d  SXn 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   __exit__t	   __enter__t   syst   stdoutt   flusht   UnicodeEncodeErrort   warn(   R   t   oldt   newR	   t   equalt
   diff_linest   line(    (    s"   /usr/lib/python2.6/lib2to3/main.pyt   print_output;   s&    
 	 (   t   __name__t
   __module__t   __doc__R   R   R"   R9   (    (    (    s"   /usr/lib/python2.6/lib2to3/main.pyR      s
   			c         C€  s   t  i d |  f IJd  S(   Ns   WARNING: %s(   R/   t   stderr(   R   (    (    s"   /usr/lib/python2.6/lib2to3/main.pyR3   Q   s    c         €  s)  t  i d d ƒ } | i d d d d d d ƒ| i d	 d
 d d d g  d d ƒ| i d d d d d d d d d d ƒ| i d d d d d g  d d ƒ| i d d d d d d ƒ| i d d d d d d ƒ| i d d d d d d  ƒ| i d! d d d d" ƒ| i d# d$ d d d d% ƒ| i d& d' d d d t d d( ƒt } h  } | i | ƒ \ } } | i o | i o t d) ƒ n | i o | i o | i	 d* ƒ n | i
 o4 d+ GHx t i ˆ  ƒ D] } | GHqÎW| p d, Sn | p t i d- IJt i d. IJd/ Sd0 | j o& t } | i o t i d1 IJd/ Sn | i o t | d2 <n | i o
 t i n t i } t i d3 d4 d5 | ƒ t t i ˆ  ƒ ƒ } t ‡  f d6 †  | i Dƒ ƒ }	 t ƒ  }
 | i og t } x= | i D]2 } | d7 j o
 t } qè|
 i ˆ  d8 | ƒ qèW| o | i |
 ƒ n |
 } n | i |
 ƒ } | i |	 ƒ } t t | ƒ | t |
 ƒ | i | i ƒ } | i p„ | o | i  ƒ  nb y# | i | | i | i! | i" ƒ Wn; t i# j
 o, | i" d j p t$ ‚ t i d9 IJd SX| i% ƒ  n t& t' | i ƒ ƒ S(:   sþ   Main program.

    Args:
        fixer_pkg: the name of a package where the fixers are located.
        args: optional; a list of command line arguments. If omitted,
              sys.argv[1:] is used.

    Returns a suggested exit status (0, 1, 2).
    t   usages   2to3 [options] file|dir ...s   -ds   --doctests_onlyt   actiont
   store_truet   helps   Fix up doctests onlys   -fs   --fixR   t   defaults1   Each FIX specifies a transformation; default: alls   -js   --processest   storei   t   typet   ints   Run 2to3 concurrentlys   -xs   --nofixs   Prevent a fixer from being run.s   -ls   --list-fixess   List available transformationss   -ps   --print-functions0   Modify the grammar so that print() is a functions   -vs	   --verboses   More verbose loggings
   --no-diffss#   Don't show diffs of the refactorings   -ws   --writes   Write back modified filess   -ns   --nobackupss'   Don't write backups for modified files.s@   not writing files and not printing diffs; that's not very usefuls   Can't use -n without -ws2   Available transformations for the -f/--fix option:i    s1   At least one file or directory argument required.s   Use --help to show usage.i   t   -s   Can't write to stdin.t   print_functiont   formats   %(name)s: %(message)st   levelc         3€  s!   x |  ] } ˆ  d  | Vq Wd S(   s   .fix_N(    (   t   .0t   fix(   t	   fixer_pkg(    s"   /usr/lib/python2.6/lib2to3/main.pys	   <genexpr>–   s   	 t   alls   .fix_s+   Sorry, -j isn't supported on this platform.((   t   optparset   OptionParsert
   add_optiont   Falset
   parse_argsR*   t   no_diffsR3   R   R   t
   list_fixesR   t   get_all_fix_namesR/   R=   t   TrueRG   t   verboset   loggingt   DEBUGt   INFOt   basicConfigt   sett   get_fixers_from_packaget   nofixRK   t   addt   uniont
   differenceR   t   sortedR   t   refactor_stdint   doctests_onlyt	   processest   MultiprocessingUnsupportedt   AssertionErrort	   summarizeRE   t   bool(   RL   R   t   parserRc   t   flagsR   t   fixnameRI   t   avail_fixest   unwanted_fixesR   t   all_presentRK   t	   requestedt   fixer_namest   rt(    (   RL   s"   /usr/lib/python2.6/lib2to3/main.pyt   mainU   s–    
 		
	
	

 
!
(   R<   t
   __future__R    R/   R   R   RX   R#   RN   R   R   R
   t   MultiprocessRefactoringToolR   R3   R,   Rs   (    (    (    s"   /usr/lib/python2.6/lib2to3/main.pyt   <module>   s   		7	