Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.191.144.73
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : btm_utils.cpython-310.pyc
o

_b�&�@s|dZddlmZddlmZmZddlmZmZeZ	eZ
ejZeZ
dZdZdZGdd	�d	e�Zddd�Zd
d�Zdd�Zd
S)z0Utility functions used by the btm_matcher module�)�pytree)�grammar�token)�pattern_symbols�python_symbols���������c@s:eZdZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�MinNodez�This class serves as an intermediate representation of the
    pattern tree during the conversion to sets of leaf-to-root
    subpatternsNcCs.||_||_g|_d|_d|_g|_g|_dS)NF)�type�name�children�leaf�parent�alternatives�group)�selfrr�r�:/usr/local/python-3.10/lib/python3.10/lib2to3/btm_utils.py�__init__s
zMinNode.__init__cCst|j�dt|j�S)N� )�strrr)rrrr�__repr__szMinNode.__repr__cCs�|}g}|rt|jtkr0|j�|�t|j�t|j�kr(t|j�g}g|_|j}q|j}d}	|S|jtkrY|j	�|�t|j	�t|j�krQt
|j	�}g|_	|j}q|j}d}	|S|jtjkri|j
ri|�|j
�n|�|j�|j}|s|S)z�Internal method. Returns a characteristic path of the
        pattern tree. This method must be run for all leaves until the
        linear subpatterns are merged into a singleN)r�TYPE_ALTERNATIVESr�append�lenr
�tupler�
TYPE_GROUPr�get_characteristic_subpattern�token_labels�NAMEr)r�node�subprrr�leaf_to_root!s>

�
	��"zMinNode.leaf_to_rootcCs&|��D]}|��}|r|SqdS)a�Drives the leaf_to_root method. The reason that
        leaf_to_root must be run multiple times is because we need to
        reject 'group' matches; for example the alternative form
        (a | b c) creates a group [b c] that needs to be matched. Since
        matching multiple linear patterns overcomes the automaton's
        capabilities, leaf_to_root merges each group into a single
        choice based on 'characteristic'ity,

        i.e. (a|b c) -> (a|b) if b more characteristic than c

        Returns: The most 'characteristic'(as defined by
          get_characteristic_subpattern) path for the compiled pattern
          tree.
        N)�leavesr#)r�lr"rrr�get_linear_subpatternKs��zMinNode.get_linear_subpatternccs0�|jD]	}|��EdHq|js|VdSdS)z-Generator that returns the leaves of the treeN)r
r$)r�childrrrr$`s�

�zMinNode.leaves)NN)	�__name__�
__module__�__qualname__�__doc__rrr#r&r$rrrrr
s
	*r
Nc
Cs�d}|jtjkr
|jd}|jtjkrIt|j�dkr$t|jd|�}�q�ttd�}|jD]}|j�	|�dr7q,t||�}|durF|j�
|�q,�nz|jtjkrt|j�dkruttd�}|jD]}t||�}|rm|j�
|�q^|jssd}�q�t|jd|�}�nD|jtj
k�r�t|jdtj�r�|jdjdkr�t|jd|�St|jdtj�r�|jdjdks�t|j�dkr�t|jdd�r�|jdjdkr�dSd	}d}d}d
}d}	d
}
|jD].}|jtjkr�d
}|}n|jtjkr�d	}|}	n|jtjkr�|}t|d��r|jdk�rd	}
q�|
�r!|jd}t|d��r |jdk�r |jd}n|jd}|jtjk�rV|jd
k�r:ttd�}�q�tt|j��rLttt|j�d�}�q�ttt|j�d�}n/|jtjk�ry|j�d�}|tv�rqtt|d�}�q�ttj|d�}n|jtjk�r�t||�}|�r�|	jdjdk�r�d}n|	jdjdk�r�nt�|�r�|du�r�|jdd�D]}t||�}|du�r�|j�
|��q�|�r�||_|S)z�
    Internal function. Reduces a compiled pattern tree to an
    intermediate representation suitable for feeding the
    automaton. This also trims off any optional pattern elements(like
    [a], a*).
    N��)rr�(�[�valueTF�=��any�')rr�*�+r)r�symsZMatcherr
ZAlternativesr�reduce_treer
r�indexrZAlternativerZUnit�
isinstancerZLeafr0�hasattrZDetailsZRepeaterrr �TYPE_ANY�getattr�pysyms�STRING�strip�tokens�NotImplementedErrorr)
r!rZnew_noder'ZreducedrZdetails_nodeZalternatives_nodeZhas_repeaterZ
repeater_nodeZhas_variable_nameZ	name_leafrrrrr8gs�



��


�������
�

�




�r8cs�t|t�s|St|�dkr|dSg}g}gd��g}d�|D]2}tt|dd���rQtt|�fdd���r;|�|�qtt|�fdd���rL|�|�q|�|�q|rW|}n	|r\|}n|r`|}t|td	�S)
z�Picks the most characteristic from a list of linear patterns
    Current order used is:
    names > common_names > common_chars
    rr,)�in�for�if�not�Nonez[]().,:cSst|�tuS�N)rr��xrrr�<lambda>�sz/get_characteristic_subpattern.<locals>.<lambda>c�t|t�o|�vSrH�r:rrI)�common_charsrrrK�crLrHrMrI)�common_namesrrrKrO)�key)r:�listrr3�rec_testr�max)ZsubpatternsZsubpatterns_with_namesZsubpatterns_with_common_namesZsubpatterns_with_common_chars�
subpatternr)rNrPrr�s8

�
�
�rccs:�|D]}t|ttf�rt||�EdHq||�VqdS)zPTests test_func on all items of sequence and items of included
    sub-iterablesN)r:rRrrS)ZsequenceZ	test_funcrJrrrrSs��rSrH)r+�rZpgen2rrZpygramrrr7r>ZopmaprArr<rr�objectr
r8rrSrrrr�<module>s 
W%
© 2025 GrazzMean