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_tuple_params.cpython-311.pyc

�

�f����dZddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZmZd�Z
Gd�dej��Zd	�Zd
�Zgdfd�Zd
�ZdS)a:Fixer for function definitions with tuple parameters.

def func(((a, b), c), d):
    ...

    ->

def func(x, d):
    ((a, b), c) = x
    ...

It will also support lambdas:

    lambda (x, y): x + y -> lambda t: t[0] + t[1]

    # The parens are a syntax error in Python 3
    lambda (x): x + y -> lambda x: x + y
�)�pytree)�token)�
fixer_base)�Assign�Name�Newline�Number�	Subscript�symsc�v�t|tj��o|jdjt
jkS)N�)�
isinstancer�Node�children�typer�STRING)�stmts �E/opt/alt/python311/lib64/python3.11/lib2to3/fixes/fix_tuple_params.py�is_docstringrs/���d�F�K�(�(�1��=��� �E�L�0�1�c�&�eZdZdZdZdZd�Zd�ZdS)�FixTupleParams�Ta
              funcdef< 'def' any parameters< '(' args=any ')' >
                       ['->' any] ':' suite=any+ >
              |
              lambda=
              lambdef< 'lambda' args=vfpdef< '(' inner=any ')' >
                       ':' body=any
              >
              c����
�d|vr��||��Sg�
|d}|d}|djdjtjkr)d}|djdj}t
���n#d}d}tjtjd���d
��
�fd
�	}|jtj
kr||��nU|jtjkr@t|j��D]+\}}	|	jtj
kr||	|dk����,�
sdS�
D]}
|d|
_
�|}|dkrd�
d_n2t|dj|��r|�
d_|dz}�
D]}
|d|
_
��
|dj||�<t!|dz|t#�
��zdz��D]}||dj|_�|d���dS)N�lambda�suite�argsr
�rz; �Fc���t������}|���}d|_t	||�����}|rd|_|�|����tjtj
|����g����dS)Nr� )r�new_name�clone�prefixr�replace�appendrrr�simple_stmt)�	tuple_arg�
add_prefix�n�argr�end�	new_lines�selfs     ���r�handle_tuplez.FixTupleParams.transform.<locals>.handle_tupleCs�����T�]�]�_�_�%�%�A��/�/�#�#�C��C�J��#�q�w�w�y�y�)�)�D��
�������a� � � ����V�[��)9�*.��	�	���)<�>�>�
?�
?�
?�
?�
?r)r)r!)F)�transform_lambdarrr�INDENT�valuerr�Leafr�tfpdef�
typedargslist�	enumerate�parentr$r�range�len�changed)r.�node�resultsrr�start�indentr/�ir+�line�afterr,r-s`           @@r�	transformzFixTupleParams.transform.sM������w����(�(��w�7�7�7��	��� ���v�����8��Q��$���4�4��E��1�X�&�q�)�/�F��)�)�C�C��E��F��+�e�l�B�/�/�C�
		?�		?�		?�		?�		?�		?�		?�		?��9���#�#��L������
�Y�$�,�
,�
,�#�D�M�2�2�
:�
:���3��8�t�{�*�*�!�L��!�a�%�9�9�9�9���	��F��	#�	#�D���(�D�K�K����A�:�:�"%�I�a�L���
�%��(�+�E�2�
3�
3�	�"(�I�a�L���A�I�E��	#�	#�D���(�D�K�K�)2��a���%��+�&��u�Q�w��c�)�n�n� 4�Q� 6�7�7�	1�	1�A�*0�E�!�H��a� �'�'�
�a��������rc��|d}|d}t|d��}|jtjkr2|���}d|_|�|��dSt|��}t|��}|�	t|����}t|d���}	|�|	�����|���D]�}
|
jtjkrv|
j
|vrmd�||
j
D��}tjt j|	���g|z��}|
j|_|
�|����dS)Nr�body�innerr!)r$c�6�g|]}|�����S�)r#��.0�cs  r�
<listcomp>z3FixTupleParams.transform_lambda.<locals>.<listcomp>�s ��C�C�C�A�a�g�g�i�i�C�C�Cr)�
simplify_argsrr�NAMEr#r$r%�find_params�map_to_indexr"�
tuple_namer�
post_orderr2rrr�power)
r.r;r<rrDrE�params�to_index�tup_name�	new_paramr*�
subscripts�news
             rr0zFixTupleParams.transform_lambdans`���v����v����g�g�.�/�/���:���#�#��K�K�M�M�E��E�L��L�L������F��T�"�"����'�'���=�=��F�!3�!3�4�4����#�.�.�.�	����Y�_�_�&�&�'�'�'����"�"�	�	�A��v���#�#���8�(;�(;�C�C��!�'�1B�C�C�C�
��k�$�*�#,�?�?�#4�#4�"5�
�"B�D�D���X��
��	�	�#�����
	�	rN)�__name__�
__module__�__qualname__�	run_order�
BM_compatible�PATTERNrBr0rGrrrrsD�������I��M��G�>�>�>�@����rrc��|jtjtjfvr|S|jtjkr9|jtjkr"|jd}|jtjk�"|Std|z���)NrzReceived unexpected node %s)rr�vfplistrrM�vfpdefr�RuntimeError�r;s rrLrL�ss���y�T�\�5�:�.�.�.���	
��d�k�	!�	!��i�4�;�&�&��=��#�D��i�4�;�&�&���
�4�t�;�
<�
<�<rc��|jtjkrt|jd��S|jt
jkr|jSd�|jD��S)Nrc�V�g|]&}|jtjk�t|����'SrG)rr�COMMArNrHs  rrKzfind_params.<locals>.<listcomp>�s,��K�K�K�q�Q�V�u�{�5J�5J�K��N�N�5J�5J�5Jr)rrrarNrrrMr2rcs rrNrN�sS���y�D�K����4�=��+�,�,�,�	
��e�j�	 �	 ��z��K�K�D�M�K�K�K�KrNc���|�i}t|��D]_\}}ttt|������g}t	|t
��rt
|||����W||z||<�`|S)N)�d)r6r
r	�strr�listrO)�
param_listr$rhr?�obj�trailers      rrOrO�s����y����J�'�'�&�&���3��V�C��F�F�^�^�,�,�-���c�4� � �	&���g��+�+�+�+�+��g�%�A�c�F�F��Hrc���g}|D]O}t|t��r#|�t|�����:|�|���Pd�|��S)N�_)rrjr&rP�join)rk�lrls   rrPrP�sd��
�A������c�4� � �	�
�H�H�Z��_�_�%�%�%�%�
�H�H�S�M�M�M�M��8�8�A�;�;�r)�__doc__rr�pgen2rr�
fixer_utilrrrr	r
rr�BaseFixrrLrNrOrPrGrr�<module>rvs����*������������������G�G�G�G�G�G�G�G�G�G�G�G�G�G�G�G�1�1�1�g�g�g�g�g�Z�'�g�g�g�X	=�	=�	=�L�L�L�%'�$�	
�	
�	
�	
�����r

Zerion Mini Shell 1.0