ok

Mini Shell

Direktori : /opt/alt/python311/lib64/python3.11/lib2to3/fixes/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/lib2to3/fixes/__pycache__/fix_metaclass.cpython-311.pyc

�

�f ���dZddlmZddlmZddlmZmZmZd�Z	d�Z
d�Zd�Zd	�Z
d
�ZGd�dej��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�|jD]�}|jtjkrt	|��cS|jtjkr`|jrY|jd}|jtjkr7|jr0|jd}t|t��r|j	dkrdS��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.pyrrs�����	 �	 ���9��
�"�"� ��&�&�&�&�&�
�Y�$�*�
*�
*�t�}�
*��
�a�(�I��~���/�/�I�4F�/�%�.�q�1�	��i��.�.� �!��?�:�:��4�4���5�c�
�|jD]}|jtjkrdS�t	|j��D]\}}|jt
jkrn�td���ttjg��}|j|dzd�r]|j|dz}|�	|�
����|���|j|dzd��]|�	|��|}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 ':'!�)rrrr
�	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�Drc�n�t|j��D]\}}|jtjkrn�dS|���t
tjg��}t
tj	|g��}|j|d�rW|j|}|�
|�����|���|j|d��W|�||��|jdjd}|jdjd}	|	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	)rrrr�SEMIr rrrrrr�insert_child�prefix)
rr"�	stmt_node�semi_indr�new_expr�new_stmtr#�	new_leaf1�	old_leaf1s
          r�fixup_simple_stmtr/Gs.��
$�I�$6�7�7�����$��9��
�"�"��E�#�	���K�K�M�M�M��D�N�B�'�'�H��D�$�x�j�1�1�H�
�
�X�Y�Y�
'���&�x�0�	����i�o�o�/�/�0�0�0��������
�X�Y�Y�
'������8�$�$�$��!�!�$�-�a�0�I��"�1�%�.�q�1�I� �'�I���rc��|jrA|jdjtjkr#|jd���dSdSdS)N���)rrr�NEWLINEr )rs r�remove_trailing_newliner3_sQ���}�#���r�*�/�5�=�@�@��
�b�� � �"�"�"�"�"�#�#�@�@rc#��K�|jD]}|jtjkrn�t	d���tt
|j����D]�\}}|jtjkr�|jr}|jd}|jtjkr[|jrT|jd}t|t��r2|jdkr't|||��t|��|||fV���dS)NzNo class suite!r	r
)rrrr
r�listrrrrrrr/r3)r!rr"�simple_noder�	left_nodes      r�
find_metasr8ds�����!�,�,���9��
�"�"��E�#��*�+�+�+��y���7�7�8�8�1�1���;���t�/�/�/�K�4H�/�#�,�Q�/�I��~���/�/�I�4F�/�%�.�q�1�	��i��.�.�1�!��?�:�:�%�d�A�{�;�;�;�+�K�8�8�8���K�0�0�0�0��1�1rc�p�|jddd�}|r,|���}|jtjkrn|�,|ru|���}t|t��r%|jtjkr|jrd|_dS|�	|jddd���|�sdSdS)z� If an INDENT is followed by a thing with a prefix then nuke the prefix
        Otherwise we get in trouble when removing __metaclass__ at suite start
    Nr1�)
r�poprr�INDENTrr�DEDENTr(�extend)r
�kidsrs   r�fixup_indentr@{s����>�$�$�B�$��D�
���x�x�z�z���9���$�$�����-��x�x�z�z���d�D�!�!�	-�d�i�5�<�&?�&?��{�
!� ����F��K�K��
�d�d��d�+�,�,�,��-�-�-�-�-rc��eZdZdZdZd�ZdS)�FixMetaclassTz
    classdef<any*>
    c���t|��sdSt|��d}t|��D]\}}}|}|����|jdj}t
|j��dkr�|jdjtjkr|jd}�nN|jd�	��}	ttj|	g��}|�d|��n�t
|j��dkr1ttjg��}|�d|��n�t
|j��dkr�ttjg��}|�dttjd����|�d|��|�dttjd����nt#d	���|jdjd}
d
|
_|
j}|jr5|�ttjd����d|
_nd
|
_|jd}|jtjksJ�d
|jd_d
|jd_|�|��t/|��|jso|���t|d��}
||
_|�|
��|�ttjd����dSt
|j��dkr�|jdjtjkrx|jdjtjkrZt|d��}
|�d|
��|�dttjd����dSdSdSdS)Nr	����r�)�(zUnexpected class definition�	metaclass�,� r:r�pass�
���r1)rr$r8r rr�lenr�arglistrr�	set_childr'rr�RPAR�LPARrrr(r�COMMArr@r2r<r=)�selfr�results�last_metaclassr
r"�stmt�	text_typerQr�meta_txt�orig_meta_prefixr�	pass_leafs              r�	transformzFixMetaclass.transform�s����T�"�"�	��F��������(��.�.�	�	�N�E�1�d�!�N��K�K�M�M�M�M��M�!�$�)�	��t�}����"�"��}�Q��$���4�4��-��*�����q�)�/�/�1�1���t�|�f�X�6�6�����q�'�*�*�*�*�
���
�
�1�
$�
$��4�<��,�,�G����a��)�)�)�)�
���
�
�1�
$�
$��4�<��,�,�G����a��e�j�#�!6�!6�7�7�7����a��)�)�)����a��e�j�#�!6�!6�7�7�7�7��:�;�;�;�"�*�1�-�6�q�9��$���#�?����	!�� � ��e�k�3�!7�!7�8�8�8�!�H�O�O� �H�O�#�+�A�.�	��~���/�/�/�/�')�	��1��$�')�	��1��$����^�,�,�,��U�����~�	>��L�L�N�N�N��Y��/�/�I�/�I�����i�(�(�(����d�5�=�$�7�7�8�8�8�8�8�
���
 �
 �1�
$�
$��.��$�)�U�\�9�9��.��$�)�U�\�9�9��Y��/�/�I����r�9�-�-�-����r�4��
�t�#<�#<�=�=�=�=�=�
%�
$�9�9�9�9rN)�__name__�
__module__�__qualname__�
BM_compatible�PATTERNr^�rrrBrB�s4�������M��G�L>�L>�L>�L>�L>rrBN)�__doc__r:r�pygramr�
fixer_utilrrrrr$r/r3r8r@�BaseFixrBrdrr�<module>ris�����(������������)�)�)�)�)�)�)�)�)�)����&���4(�(�(�0#�#�#�
1�1�1�.-�-�-�,S>�S>�S>�S>�S>�:�%�S>�S>�S>�S>�S>r

Zerion Mini Shell 1.0