ó
è¾bc           @   sš   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z m	 Z	 m
 Z
 m Z m Z e j d ƒ Z d e j f d	 „  ƒ  YZ d
 S(   s  Fixer for print.

Change:
    'print'          into 'print()'
    'print ...'      into 'print(...)'
    'print ... ,'    into 'print(..., end=" ")'
    'print >>x, ...' into 'print(..., file=x)'

No changes are applied if print_function is imported from __future__

i   (   t   patcomp(   t   pytree(   t   token(   t
   fixer_base(   t   Namet   Callt   Commat   Stringt   is_tuples"   atom< '(' [atom|STRING|NAME] ')' >t   FixPrintc           B   s&   e  Z e Z d  Z d „  Z d „  Z RS(   sP   
              simple_stmt< any* bare='print' any* > | print_stmt
              c         C   s2  | s t  ‚ | j d ƒ } | rJ | j t t d ƒ g  d | j ƒƒ d  S| j d t d ƒ k si t  ‚ | j d } t | ƒ d k rŸ t j	 | d ƒ rŸ d  Sd  } } } | rÙ | d t ƒ  k rÙ | d  } d } n  | r3| d t j t j d ƒ k r3t | ƒ d	 k st  ‚ | d j ƒ  } | d
 } n  g  | D] } | j ƒ  ^ q:}	 |	 rhd |	 d _ n  | d  k	 sŒ| d  k	 sŒ| d  k	 r| d  k	 rº|  j |	 d t t | ƒ ƒ ƒ n  | d  k	 rè|  j |	 d t t | ƒ ƒ ƒ n  | d  k	 r|  j |	 d | ƒ qn  t t d ƒ |	 ƒ }
 | j |
 _ |
 S(   Nt   bareu   printt   prefixi    i   iÿÿÿÿt    u   >>i   i   u    u   sepu   endu   file(   t   AssertionErrort   gett   replaceR   R   R   t   childrent   lent   parend_exprt   matcht   NoneR   R   t   LeafR   t
   RIGHTSHIFTt   clonet	   add_kwargR   t   repr(   t   selft   nodet   resultst
   bare_printt   argst   sept   endt   filet   argt   l_argst   n_stmt(    (    s-   /usr/lib/python2.7/lib2to3/fixes/fix_print.pyt	   transform%   s>    %
	%$""c         C   sr   d | _  t j |  j j t | ƒ t j t j d ƒ | f ƒ } | ra | j	 t
 ƒ  ƒ d | _  n  | j	 | ƒ d  S(   Nu    u   =u    (   R   R   t   Nodet   symst   argumentR   R   R   t   EQUALt   appendR   (   R   t   l_nodest   s_kwdt   n_exprt
   n_argument(    (    s-   /usr/lib/python2.7/lib2to3/fixes/fix_print.pyR   M   s    		(   t   __name__t
   __module__t   Truet   BM_compatiblet   PATTERNR%   R   (    (    (    s-   /usr/lib/python2.7/lib2to3/fixes/fix_print.pyR	      s   	(N(   t   __doc__t    R    R   t   pgen2R   R   t
   fixer_utilR   R   R   R   R   t   compile_patternR   t   BaseFixR	   (    (    (    s-   /usr/lib/python2.7/lib2to3/fixes/fix_print.pyt   <module>   s   (	