Hacked By AnonymousFox
o
6��f � @ sv d Z ddlmZ ddlmZ ddlmZmZmZ dd� Z dd� Z
d d
� Zdd� Zd
d� Z
dd� ZG dd� dej�ZdS )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 C sz | j D ]7}|jtjkrt|� S |jtjkr:|j r:|j d }|jtjkr:|j r:|j d }t|t�r:|j dkr: dS qdS )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_nodeZ left_side� r �B/opt/alt/python310/lib64/python3.10/lib2to3/fixes/fix_metaclass.pyr s
�r c C s� | j D ]}|jtjkr dS qt| j �D ]\}}|jtjkr nqtd��ttjg �}| j |d d� rO| j |d }|� |�
� � |�� | j |d d� s4| � |� |}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_noder r r �fixup_parse_tree- s"