ó
ñsºec           @   sg   d  Z  d d l m Z m Z d d l m Z m Z m Z m Z m	 Z	 m
 Z
 d e j f d „  ƒ  YZ d S(   s7   
Convert use of sys.exitfunc to use the atexit module.
iÿÿÿÿ(   t   pytreet
   fixer_base(   t   Namet   Attrt   Callt   Commat   Newlinet   symst   FixExitfuncc           B   s5   e  Z e Z e Z d  Z d „  Z d „  Z d „  Z RS(   s”  
              (
                  sys_import=import_name<'import'
                      ('sys'
                      |
                      dotted_as_names< (any ',')* 'sys' (',' any)* >
                      )
                  >
              |
                  expr_stmt<
                      power< 'sys' trailer< '.' 'exitfunc' > >
                  '=' func=any >
              )
              c         G   s   t  t |  ƒ j | Œ  d  S(   N(   t   superR   t   __init__(   t   selft   args(    (    s0   /usr/lib/python2.7/lib2to3/fixes/fix_exitfunc.pyR
      s    c         C   s&   t  t |  ƒ j | | ƒ d  |  _ d  S(   N(   R	   R   t
   start_treet   Nonet
   sys_import(   R   t   treet   filename(    (    s0   /usr/lib/python2.7/lib2to3/fixes/fix_exitfunc.pyR   !   s    c         C   s   d | k r/ |  j  d  k r+ | d |  _  n  d  S| d j ƒ  } d | _ t j t j t t	 d ƒ t	 d ƒ ƒ ƒ } t
 | | g | j ƒ } | j | ƒ |  j  d  k rº |  j | d ƒ d  S|  j  j d } | j t j k r| j t ƒ  ƒ | j t	 d d ƒ ƒ n— |  j  j } | j j |  j  ƒ } | j }	 t j t j t	 d	 ƒ t	 d d ƒ g ƒ }
 t j t j |
 g ƒ } | j | d t ƒ  ƒ | j | d
 | ƒ d  S(   NR   t   funcu    u   atexitu   registersK   Can't find sys import; Please add an atexit import at the top of your file.i   u    u   importi   (   R   R   t   clonet   prefixR    t   NodeR   t   powerR   R   R   t   replacet   warningt   childrent   typet   dotted_as_namest   append_childR   t   parentt   indext   import_namet   simple_stmtt   insert_childR   (   R   t   nodet   resultsR   t   registert   callt   namest   containing_stmtt   positiont   stmt_containert
   new_importt   new(    (    s0   /usr/lib/python2.7/lib2to3/fixes/fix_exitfunc.pyt	   transform%   s2    		(	   t   __name__t
   __module__t   Truet   keep_line_ordert   BM_compatiblet   PATTERNR
   R   R,   (    (    (    s0   /usr/lib/python2.7/lib2to3/fixes/fix_exitfunc.pyR      s   		N(   t   __doc__t   lib2to3R    R   t   lib2to3.fixer_utilR   R   R   R   R   R   t   BaseFixR   (    (    (    s0   /usr/lib/python2.7/lib2to3/fixes/fix_exitfunc.pyt   <module>   s   .