Viewing File: /opt/alt/python312/lib64/python3.12/lib2to3/fixes/__pycache__/fix_filter.cpython-312.pyc

�

<��i�
��r�dZddlmZddlmZddlmZddlm	Z	m
Z
mZmZm
Z
Gd�dej�Zy)	a�Fixer that changes filter(F, X) into list(filter(F, X)).

We avoid the transformation if the filter() call is directly contained
in iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or
for V in <>:.

NOTE: This is still not correct if the original code was depending on
filter(F, X) to return a string if X is a string and a tuple if X is a
tuple.  That would require type inference, which we don't do.  Let
Python 2.6 figure it out.
�)�
fixer_base)�Node)�python_symbols)�Name�ArgList�ListComp�in_special_context�parenthesizec��eZdZdZdZdZd�Zy)�	FixFilterTaV
    filter_lambda=power<
        'filter'
        trailer<
            '('
            arglist<
                lambdef< 'lambda'
                         (fp=NAME | vfpdef< '(' fp=NAME ')'> ) ':' xp=any
                >
                ','
                it=any
            >
            ')'
        >
        [extra_trailers=trailer*]
    >
    |
    power<
        'filter'
        trailer< '(' arglist< none='None' ',' seq=any > ')' >
        [extra_trailers=trailer*]
    >
    |
    power<
        'filter'
        args=trailer< '(' [any] ')' >
        [extra_trailers=trailer*]
    >
    zfuture_builtins.filterc��|j|�ryg}d|vr)|dD]!}|j|j���#d|vr�|jd�j�}|jt
jk(rd|_t|�}t|jd�j�|jd�j�|jd�j�|�}tt
j|g|zd��}n�d|vr[ttd	�td	�|d
j�td	��}tt
j|g|zd��}nt|�ry|dj�}tt
jtd�|gd��}tt
jtd
�t|g�g|z�}d|_|j|_|S)N�extra_trailers�
filter_lambda�xp��fp�it)�prefix�none�_f�seq�args�filter�list)�should_skip�append�clone�get�type�syms�testrr
rr�powerrr	r)�self�node�results�trailers�tr�newrs        �?/opt/alt/python312/lib64/python3.12/lib2to3/fixes/fix_filter.py�	transformzFixFilter.transform:s������D�!�����w�&��-�.��������	�*�/��g�%����T�"�(�(�*�B��w�w�$�)�)�#���	�!�"�%���7�;�;�t�,�2�2�4�"�;�;�t�,�2�2�4�"�;�;�t�,�2�2�4�b�:�C��t�z�z�C�5�8�#3�B�?�C�
�w�
��4��:���:�"�5�>�/�/�1���:�'�C��t�z�z�C�5�8�#3�B�?�C�"�$�'���6�?�(�(�*�D��t�z�z�D��N�D�#9�"�E�C��t�z�z�D��L�'�3�%�.�#A�H�#L�M�C��C�J��[�[��
��
�N)�__name__�
__module__�__qualname__�
BM_compatible�PATTERN�skip_onr*�r+r)rrs���M��G�<'�G�$r+rN)�__doc__rr�pytreer�pygramrr �
fixer_utilrrrr	r
�ConditionalFixrr2r+r)�<module>r8s/��
���+�R�R�G�
�)�)�Gr+
Back to Directory File Manager