ok
Direktori : /opt/alt/python311/lib64/python3.11/lib2to3/fixes/__pycache__/ |
Current File : //opt/alt/python311/lib64/python3.11/lib2to3/fixes/__pycache__/fix_metaclass.cpython-311.pyc |
� �f � � � d Z ddlmZ ddlmZ ddlmZmZmZ d� Z d� Z d� Zd� Zd � Z d � Z G d� dej � � Zd S )a� Fixer for __metaclass__ = X -> (metaclass=X) methods. The various forms of classef (inherits nothing, inherits once, inherits many) don't parse the same in the CST so we look at ALL classes for a __metaclass__ and if we find one normalize the inherits to all be an arglist. For one-liner classes ('class X: pass') there is no indent/dedent so we normalize those into having a suite. Moving the __metaclass__ into the classdef can also cause the class body to be empty so there is some special casing for that as well. This fixer also tries very hard to keep original indenting and spacing in all those corner cases. � )� fixer_base)�token)�syms�Node�Leafc �P � | j D ]�}|j t j k rt |� � c S |j t j k r`|j rY|j d }|j t j k r7|j r0|j d }t |t � � r|j dk r dS ��dS )z� we have to check the cls_node without changing it. There are two possibilities: 1) clsdef => suite => simple_stmt => expr_stmt => Leaf('__meta') 2) clsdef => simple_stmt => expr_stmt => Leaf('__meta') � � __metaclass__TF) �children�typer �suite� has_metaclass�simple_stmt� expr_stmt� isinstancer �value)�parent�node� expr_node� left_sides �B/opt/alt/python311/lib64/python3.11/lib2to3/fixes/fix_metaclass.pyr r s� � � �� � ���9�� �"�"� ��&�&�&�&�&� �Y�$�*� *� *�t�}� *�� �a�(�I��~���/�/�I�4F�/�%�.�q�1� ��i��.�.� �!��?�:�:��4�4���5� c � � | j D ]}|j t j k r dS �t | j � � D ]\ }}|j t j k r n�t d� � �t t j g � � }| j |dz d� r]| j |dz }|� |� � � � � |� � � | j |dz d� �]| � |� � |}dS )zf one-line classes don't get a suite in the parse tree so we add one to normalize the tree NzNo class suite and no ':'!� )r r r r � enumerater �COLON� ValueErrorr �append_child�clone�remove)�cls_noder �ir � move_nodes r �fixup_parse_treer$ - s � � �!� � ���9�� �"�"��F�F� #� �X�.�/�/� 7� 7���4��9���#�#��E� $� �5�6�6�6� ���R� � �E� � �A�a�C�D�D� !� ��%�a��c�*� � ���9�?�?�,�,�-�-�-������� � �A�a�C�D�D� !� � ���%� � � ��D�D�Dr c �n � t |j � � D ]\ }}|j t j k r n�dS |� � � t t j g � � }t t j |g� � }|j |d� rW|j | }|� |� � � � � |� � � |j |d� �W| � ||� � |j d j d }|j d j d } | j |_ dS )z� if there is a semi-colon all the parts count as part of the same simple_stmt. We just want the __metaclass__ part so we move everything after the semi-colon into its own simple_stmt node Nr )r r r r �SEMIr r r r r r r �insert_child�prefix) r r"