AlkantarClanX12

Your IP : 18.216.145.37


Current Path : /opt/alt/python312/lib64/python3.12/lib2to3/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/lib2to3/__pycache__/fixer_util.cpython-312.opt-1.pyc

�

�Q�ff;���dZddlmZddlmZmZddlmZddl	m
Z
d�Zd�Zd�Z
d	�Zd-d�Zd�Zd
�Zd�Ze�e
�fd�Zd.d�Zd�Zd�Zd-d�Zd�Zd-d�Zd-d�Zd�Zd�Zd�Zd�Zd�Zhd�Z d�Z!da"da#d a$d!a%d"�Z&d#�Z'd$�Z(d%�Z)d&�Z*d'�Z+d(�Z,d)�Z-ej\ej^hZ0d-d*�Z1ej^ej\ejdhZ3d+�Z4d-d,�Z5y
)/z1Utility functions, node construction macros, etc.�)�token)�Leaf�Node)�python_symbols)�patcompc�l�ttj|ttj
d�|g�S)N�=)r�syms�argumentrr�EQUAL)�keyword�values  �9/opt/alt/python312/lib64/python3.12/lib2to3/fixer_util.py�
KeywordArgrs*����
�
��$�u�{�{�C�0�%�8�:�:�c�6�ttjd�S)N�()rr�LPAR�rr�LParenr�����
�
�C� � rc�6�ttjd�S)N�))rr�RPARrrr�RParenrrrc	���t|t�s|g}t|t�s
d|_|g}ttj
|t
tjdd��gz|z�S)zBuild an assignment statement� r	��prefix)	�
isinstance�listrrr
�atomrrr)�target�sources  r�Assignr%s]���f�d�#�����f�d�#���
������	�	��$�u�{�{�C��<�=�=��F�H�HrNc�:�ttj||��S)zReturn a NAME leafr)rr�NAME)�namers  r�Namer)$s����
�
�D��0�0rc�N�|ttjt�|g�gS)zA node tuple for obj.attr)rr
�trailer�Dot)�obj�attrs  r�Attrr/(s����d�l�l�S�U�D�M�2�3�3rc�6�ttjd�S)zA comma leaf�,)rr�COMMArrr�Commar3,s������S�!�!rc�6�ttjd�S)zA period (.) leaf�.)rr�DOTrrrr,r,0s����	�	�3��rc���ttj|j�|j�g�}|r*|j	dttj
|��|S)z-A parenthesised argument list, used by Call()r)rr
r+�clone�insert_child�arglist)�args�lparen�rparen�nodes    r�ArgListr?4sF������v�|�|�~�v�|�|�~�>�?�D�����!�T�$�,�,��5�6��Krc�b�ttj|t|�g�}|�||_|S)zA function call)rr
�powerr?r)�	func_namer;rr>s    r�CallrC;s-����
�
�Y���
�6�7�D�
������Krc�6�ttjd�S)zA newline literal�
�rr�NEWLINErrr�NewlinerHBs����
�
�t�$�$rc�6�ttjd�S)zA blank line�rFrrr�	BlankLinerKFs����
�
�r�"�"rc�:�ttj||��S)Nr)rr�NUMBER)�nrs  r�NumberrOJs������a��/�/rc	��ttjttj
d�|ttjd�g�S)zA numeric or string subscript�[�])rr
r+rr�LBRACE�RBRACE)�
index_nodes r�	SubscriptrVMs8������t�E�L�L�#�6�)�#�E�L�L�#�6�8�9�9rc�:�ttj||��S)z
A string leafr)rr�STRING)�stringrs  r�StringrZSs������f�V�4�4rc	�h�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|rSd|_ttjd�}d|_|j	ttj||g��ttj|ttj|�g�}ttjttjd�|ttjd�g�S)zuA list comprehension of the form [xp for fp in it if test].

    If test is None, the "if test" part is omitted.
    rJr�for�in�ifrQrR)
rrrr'�appendrr
�comp_if�	listmaker�comp_forr"rSrT)	�xp�fp�it�test�for_leaf�in_leaf�
inner_args�if_leaf�inners	         r�ListComprlWs���
�B�I��B�I��B�I��E�J�J��&�H��H�O��5�:�:�t�$�G��G�N��B���,�J������u�z�z�4�(��������$�t�|�|�g�t�_�=�>�����"�d�4�=�=�*�&E�!F�G�E���	�	��U�\�\�3�/���U�\�\�3�/�1�2�2rc�<�|D]}|j��ttjd�ttj|d��ttjdd��t	t
j|�g}t	t
j|�}|S)zO Return an import statement in the form:
        from package import name_leafs�fromrr�import)�removerrr'rr
�import_as_names�import_from)�package_name�
name_leafs�leaf�children�imps     r�
FromImportrxosw�������
���U�Z�Z��(��U�Z�Z��c�:��U�Z�Z��#�6��T�)�)�:�6�8�H��t����
*�C��Jrc�N�|dj�}|jtjk(r|j�}n)t	tj|j�g�}|d}|r|D�cgc]}|j���}}t	tj
t
t|d�t|d��t	tj|dj�||dj�g�gz|z�}|j|_	|Scc}w)zfReturns an import statement and calls a method
    of the module:

    import module
    module.name()r-�after�r�lpar�rpar)
r8�typer
r:rrAr/r)r+r)r>�results�namesr-�
newarglistrzrN�news        r�
ImportAndCallr��s����%�.�
�
�
 �C�
�x�x�4�<�<���Y�Y�[�
��$�,�,�����
�6�
��G��E��$)�*�E�q�����E��*�
�t�z�z��D��q��N�D��q��N�3��T�\�\��f�o�+�+�-� ��f�o�+�+�-�/�0�1�1�49�	9�:�C����C�J��J��+s�6D"c���t|t�r"|jt�t	�gk(ryt|t�xr�t|j�dk(xr�t|jdt�xrxt|jdt�xrYt|jdt�xr:|jdjdk(xr|jdjdk(S)z(Does the node represent a tuple literal?T�r{r�rr)r rrvrr�lenrr�r>s r�is_tupler��s����$���$�-�-�F�H�f�h�3G�"G���t�T�"�
.��D�M�M�"�a�'�
.��4�=�=��+�T�2�
.��4�=�=��+�T�2�
.��4�=�=��+�T�2�	
.�
�
�
�a� �&�&�#�-�
.��
�
�a� �&�&�#�-�
/rc�J�t|t�xr�t|j�dkDxrxt|jdt�xrYt|jdt�xr:|jdj
dk(xr|jdj
dk(S)z'Does the node represent a list literal?rr{���rQrR)r rr�rvrrr�s r�is_listr��s����t�T�"�
/��D�M�M�"�Q�&�
/��4�=�=��+�T�2�
/��4�=�=��,�d�3�
/��
�
�a� �&�&�#�-�	
/�
�
�
�b�!�'�'�3�.�0rc�\�ttjt�|t	�g�S�N)rr
r"rrr�s r�parenthesizer��s����	�	�F�H�d�F�H�5�6�6r>
�all�any�max�min�set�sumr!�tuple�sorted�	enumeratec#�PK�t||�}|r|��t||�}|r�yy�w)alFollow an attribute chain.

    If you have a chain of objects where a.foo -> b, b.foo-> c, etc,
    use this to iterate over all objects in the chain. Iteration is
    terminated by getattr(x, attr) is None.

    Args:
        obj: the starting object
        attr: the name of the chaining attribute

    Yields:
        Each successive object in the chain.
    N)�getattr)r-r.�nexts   r�
attr_chainr��s-�����3���D�
��
��t�T�"���s�!&�&zefor_stmt< 'for' any 'in' node=any ':' any* >
        | comp_for< 'for' any 'in' node=any any* >
     z�
power<
    ( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
      'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
    trailer< '(' node=any ')' >
    any*
>
z`
power<
    ( 'sorted' | 'enumerate' )
    trailer< '(' arglist<node=any any*> ')' >
    any*
>
Fc�D�tsMtjt�atjt�atjt
�adattt
g}t
|t|d��D]#\}}i}|j||�s�|d|us�#yy)a Returns true if node is in an environment where all that is required
        of it is being iterable (ie, it doesn't matter if it returns a list
        or an iterator).
        See test_map_nochange in test_fixers.py for some examples and tests.
        T�parentr>F)	�
pats_builtr�compile_pattern�p0�p1�p2�zipr��match)r>�patterns�patternr�rs     r�in_special_contextr��s����
�
$�
$�R�
(��
�
$�
$�R�
(��
�
$�
$�R�
(���
��B��|�H��x��D�(�)C�D�������=�=���)�g�f�o��.E��E�rc��|j}|�|jtjk(ry|j}|jt
jt
jfvry|jt
jk(r|jd|ury|jt
jk(sM|jt
jk(r1|�|jtjk(s|jd|uryy)zG
    Check that something isn't an attribute or function name etc.
    Fr{T)
�prev_siblingr~rr6r�r
�funcdef�classdef�	expr_stmtrv�
parameters�
typedargslistr2)r>�prevr�s   r�is_probably_builtinr��s������D���D�I�I����2��
�[�[�F�
�{�{�t�|�|�T�]�]�3�3��
�{�{�d�n�n�$�����);�t�)C��
�{�{�d�o�o�%�
�[�[�D�.�.�
.�
�
�$�)�)�u�{�{�":��O�O�A��$�&��rc��|�||jtjk(rPt|j�dkDr8|jd}|jt
jk(r|jS|j}|��|y)zFind the indentation of *node*.r�rrJ)	r~r
�suiter�rvr�INDENTrr�)r>�indents  r�find_indentationr�sf��
�
��9�9��
�
�"�s�4�=�=�'9�A�'=��]�]�1�%�F��{�{�e�l�l�*��|�|�#��{�{���
�rc���|jtjk(r|S|j�}|jdc}|_ttj|g�}||_|Sr�)r~r
r�r8r�r)r>r�r�s   r�
make_suiter�sR���y�y�D�J�J�����:�:�<�D��+�+�t��F�D�K�����d�V�$�E��E�L��Lrc��|jtjk7r7|j}|st	d��|jtjk7r�7|S)zFind the top level namespace.z,root found before file_input node was found.)r~r
�
file_inputr��
ValueErrorr�s r�	find_rootr�&sE���)�)�t���
&��{�{����K�L�L��)�)�t���
&��Krc�D�t|t|�|�}t|�S)z� Returns true if name is imported from package at the
        top level of the tree which node belongs to.
        To cover the case of an import like 'import foo', use
        None for the package and 'foo' for the name. )�find_bindingr��bool)�packager(r>�bindings    r�does_tree_importr�/s ��
�4��4��'�:�G���=�rc�Z�|jtjtjfvS)z0Returns true if the node is an import statement.)r~r
�import_namerrr�s r�	is_importr�7s"���9�9��)�)�4�+;�+;�<�<�<rc	�H�d�}t|�}t|||�rydx}}t|j�D]>\}}||�s�t|j|d�D]\}}||�r�n||z}n|dk(ryt|j�D]a\}}|jt
jk(s�$|js�1|jdjtjk(s�\|dz}n|�Ott
jttjd�ttj|d��g�}	n't|ttj|d��g�}	|	t�g}
|j|tt
j|
��y)z\ Works like `does_tree_import` but adds an import statement
        if it was not imported. c��|jtjk(xr&|jxrt	|jd�S)Nr{)r~r
�simple_stmtrvr�r�s r�is_import_stmtz$touch_import.<locals>.is_import_stmt>s:���	�	�T�-�-�-�,�$�-�-�,��$�-�-��*�+�	-rNr{rrorr)r�r�r�rvr~r
r�rrXrr�rr'rxrHr9)r�r(r>r��root�
insert_pos�offset�idx�node2�import_rvs           r�touch_importr�;sh��-��T�?�D����t�,����J���t�}�}�-�	��T��d�#��&�t�}�}�S�T�':�;�M�F�E�!�%�(��<��6�\�
�
�.��Q��"�4�=�=�1�I�C���	�	�T�-�-�-�$�-�-��}�}�Q��$�$����4� �1�W�
��	2����t�'�'�����X�&�����T�#�.�*
���
�W�t�E�J�J��S�'I�&J�K�����#�H����j�$�t�'7�'7��"B�Crc
��|jD�]<}d}|jtjk(rGt	||jd�r|cSt|t
|jd�|�}|�r�|}�n�|jtjtjfvr*t|t
|jd�|�}|�rh|}�nd|jtjk(r�t|t
|jd�|�}|r|}�nt|jdd�D]^\}}|jtjk(s�$|jdk(s�4t|t
|j|dz�|�}|s�]|}�`n�|jtvr|jdj|k(r|}nst|||�r|}nc|jtj k(rt|||�}n8|jtj"k(rt	||jd�r|}|s��(|s|cSt%|�s��;|cSy)	z� Returns the node which binds variable name, otherwise None.
        If optional argument package is supplied, only imports will
        be returned.
        See test cases for examples.Nrr�r�r��:�r{)rvr~r
�for_stmt�_findr�r��if_stmt�
while_stmt�try_stmtr�r�COLONr�	_def_syms�_is_import_bindingr�r�r�)r(r>r��child�retrN�i�kids        rr�r�is���
�������:�:����&��T�5�>�>�!�,�-����T�:�e�n�n�R�.@�#A�7�K�A���#�
�Z�Z�D�L�L�$�/�/�:�
:��T�:�e�n�n�R�.@�#A�7�K�A���#�
�Z�Z�4�=�=�
(��T�:�e�n�n�Q�.?�#@�'�J�A����'����q�r�(:�;�F�A�s��x�x�5�;�;�.�3�9�9��3C�(��z�%�.�.��1��:M�/N�PW�X���A�c�	<�
�Z�Z�9�
$�����):�)@�)@�D�)H��C�
��t�W�
5��C�
�Z�Z�4�+�+�
+��t�U�G�4�C�
�Z�Z�4�>�>�
)��T�5�>�>�!�,�-������
���~��
�E�Frc�
�|g}|r~|j�}|jdkDr.|jtvr|j|j�n.|jt
jk(r|j|k(r|S|r�~y)N�)�popr~�_block_syms�extendrvrr'r)r(r>�nodess   rr�r��sg��
�F�E�
��y�y�{���9�9�s�?�t�y�y��;��L�L����'�
�Y�Y�%�*�*�
$����t�);��K��rc�,�|jtjk(�r9|�s6|jd}|jtjk(r�|jD]q}|jtj
k(r!|jdj|k(s�=|cS|jtjk(s�_|j|k(s�o|cSy|jtj
k(r=|jd}|jtjk(r?|j|k(r0|S|jtjk(r|j|k(r|Sy|jtjk(�r|r*t|jd�j�|k7ry|jd}|r
td|�ry|jtjk(rt||�r|S|jtjk(r>|jd}|jtjk(r|j|k(r|Sy|jtjk(r|j|k(r|S|r|jtjk(r|Sy)z� Will return node if node will import name, or node
        will import * from package.  None is returned otherwise.
        See test cases for examples. rr�r�Nr��as)r~r
r�rv�dotted_as_names�dotted_as_namerrr'rr�str�stripr�rq�import_as_name�STAR)r>r(r�rwr��lastrNs       rr�r��s���
�y�y�D�$�$�$�W��m�m�A����8�8�t�+�+�+������:�:��!4�!4�4��~�~�a�(�.�.�$�6�#���Z�Z�5�:�:�-�%�+�+��2E��K�&�>�3�X�X��,�,�
,��<�<��#�D��y�y�E�J�J�&�4�:�:��+=���
�X�X����
#��	�	�T�(9��K�(�'
���d�&�&�	&��s�4�=�=��+�,�2�2�4��?���M�M�!����u�T�1�~��
�V�V�t�+�+�
+��d�A���K�
�V�V�t�*�*�
*��J�J�q�M�E��z�z�U�Z�Z�'�E�K�K�4�,?���
�	�V�V�u�z�z�
!�a�g�g��o��K�
����5�:�:�-��K�rr�)NN)6�__doc__�pgen2r�pytreerr�pygramrr
rJrrrrr%r)r/r3r,r?rCrHrKrOrVrZrlrxr�r�r�r��consuming_callsr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r+r�r�r�rrr�<module>r�s��7���*��:�!�!�	H�1�4�"� � ��&�(���%�#�0�9�5�2�0�&�8
/�0�7�.��#�&	�������
��&�.����=�*D�Z�]�]�D�L�L�)�	�(�T�|�|�T�]�]�D�L�L�9���'r