î
\á[\Æ  ã               @   sy   d  Z  d d l m Z d d l m Z m Z m Z m Z m Z m	 Z	 m
 Z
 m Z m Z m Z Gd d „  d e j ƒ Z d S)zoFixer for execfile.

This converts usages of the execfile function into calls to the built-in
exec() function.
é   )Ú
fixer_base)
ÚCommaÚNameÚCallÚLParenÚRParenÚDotÚNodeÚArgListÚStringÚsymsc               @   s(   e  Z d  Z d Z d Z d d „  Z d S)ÚFixExecfileTz«
    power< 'execfile' trailer< '(' arglist< filename=any [',' globals=any [',' locals=any ] ] > ')' > >
    |
    power< 'execfile' trailer< '(' filename=any ')' > >
    c             C   s¦  | s t  ‚ | d } | j d ƒ } | j d ƒ } | j d j d j ƒ  } t | j ƒ  g d | ƒ} t t j t d ƒ | g ƒ } t t j	 t
 ƒ  t d ƒ g ƒ t t j	 t ƒ  t ƒ  g ƒ g }	 | g |	 }
 | j ƒ  } d | _ t d	 d ƒ } |
 t ƒ  | t ƒ  | g } t t d
 ƒ | d ƒ } | g } | d  k	 r_| j t ƒ  | j ƒ  g ƒ n  | d  k	 rŠ| j t ƒ  | j ƒ  g ƒ n  t t d ƒ | d | j ƒS)NÚfilenameÚglobalsÚlocalsé   ZrparenÚopenÚreadú z'exec'ÚcompileÚ ÚexecÚprefixéÿÿÿÿr   )ÚAssertionErrorÚgetZchildrenZcloner
   r	   r   Zpowerr   Ztrailerr   r   r   r   r   r   r   Úextend)ÚselfZnodeZresultsr   r   r   Zexecfile_parenZ	open_argsZ	open_callr   Z	open_exprZfilename_argZexec_strZcompile_argsZcompile_callÚargs© r   ú0/usr/lib/python3.4/lib2to3/fixes/fix_execfile.pyÚ	transform   s*    
!		zFixExecfile.transformN)Ú__name__Ú
__module__Ú__qualname__ZBM_compatibleZPATTERNr!   r   r   r   r    r      s   r   N)Ú__doc__r   r   Z
fixer_utilr   r   r   r   r   r   r	   r
   r   r   ZBaseFixr   r   r   r   r    Ú<module>   s   F