Your IP : 3.145.61.142
�
c��f� � �` � d Z ddlmZmZ ddlmZmZmZmZm Z m
Z
G d� dej � � ZdS )z7
Convert use of sys.exitfunc to use the atexit module.
� )�pytree�
fixer_base)�Name�Attr�Call�Comma�Newline�symsc �: � � e Zd ZdZdZdZ� fd�Z� fd�Zd� Z� xZ S )�FixExitfuncTa�
(
sys_import=import_name<'import'
('sys'
|
dotted_as_names< (any ',')* 'sys' (',' any)* >
)
>
|
expr_stmt<
power< 'sys' trailer< '.' 'exitfunc' > >
'=' func=any >
)
c �B �� t t | � � j |� d S �N)�superr �__init__)�self�args� __class__s ��A/opt/alt/python311/lib64/python3.11/lib2to3/fixes/fix_exitfunc.pyr zFixExitfunc.__init__ s# �� �)��k�4� � �)�4�0�0�0�0� c �h �� t t | � � � ||� � d | _ d S r )r r �
start_tree�
sys_import)r �tree�filenamer s �r r zFixExitfunc.start_tree! s. �� �
�k�4� � �+�+�D�(�;�;�;�����r c � � d|v r| j �
|d | _ d S |d � � � }d|_ t j t
j t t d� � t d� � � � � � }t ||g|j � � }|�
|� � | j �| � |d� � d S | j j d }|j
t
j k rF|� t! � � � � |� t dd� � � � d S | j j }|j � | j � � }|j } t j t
j t d � � t dd� � g� � }
t j t
j |
g� � }|� |dz t- � � � � |� |d
z |� � d S )Nr �func� �atexit�registerzKCan't find sys import; Please add an atexit import at the top of your file.� � �import� )r �clone�prefixr �Noder
�powerr r r �replace�warning�children�type�dotted_as_names�append_childr �parent�index�import_name�simple_stmt�insert_childr )r �node�resultsr r �call�names�containing_stmt�position�stmt_container�
new_import�news r � transformzFixExitfunc.transform% s� � ��7�"�"���&�")�,�"7����F��v��$�$�&�&������;�t�z�#�D��N�N�D��4D�4D�E�E�!� !�� �H�t�f�d�k�2�2�����T�����?�"��L�L�� ?�
@�
@�
@��F� ��(��+���:��-�-�-����u�w�w�'�'�'����t�H�c�2�2�3�3�3�3�3�"�o�4�O�&�/�5�5�d�o�F�F�H�,�3�N���T�%5�#�H�~�~�t�H�c�/B�/B�C� � �J� �+�d�.���=�=�C��(�(��A��w�y�y�A�A�A��(�(��A��s�;�;�;�;�;r )
�__name__�
__module__�__qualname__�keep_line_order�
BM_compatible�PATTERNr r r<