Hacked By AnonymousFox

Current Path : /opt/alt/python310/lib64/python3.10/lib2to3/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/lib2to3/__pycache__/fixer_util.cpython-310.opt-1.pyc

o

6��ff;�@s�dZddlmZddlmZmZddlmZddl	m
Z
dd�Zdd	�Zd
d�Z
dd
�ZdNdd�Zdd�Zdd�Zdd�Ze�e
�fdd�ZdOdd�Zdd�Zdd�ZdNdd �Zd!d"�ZdNd#d$�ZdNd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zhd1�Z d2d3�Z!d4a"d5a#d6a$d7a%d8d9�Z&d:d;�Z'd<d=�Z(d>d?�Z)d@dA�Z*dBdC�Z+dDdE�Z,dFdG�Z-ej.ej/hZ0dNdHdI�Z1ej/ej.ej2hZ3dJdK�Z4dNdLdM�Z5dS)Pz1Utility functions, node construction macros, etc.�)�token)�Leaf�Node)�python_symbols)�patcompcCsttj|ttjd�|g�S)N�=)r�symsZargumentrr�EQUAL)�keyword�value�r�9/opt/alt/python310/lib64/python3.10/lib2to3/fixer_util.py�
KeywordArgs�rcC�ttjd�S)N�()rr�LPARrrrr
�LParen�rcCr)N�))rr�RPARrrrr
�RParenrrcCsHt|t�s|g}t|t�sd|_|g}ttj|ttjddd�g|�S)zBuild an assignment statement� r��prefix)	�
isinstance�listrrr�atomrrr	)�target�sourcerrr
�Assigns

�rNcC�ttj||d�S)zReturn a NAME leafr)rr�NAME)�namerrrr
�Name$�r#cCs|ttjt�|g�gS)zA node tuple for obj.attr)rr�trailer�Dot)�obj�attrrrr
�Attr(sr)cCr)zA comma leaf�,)rr�COMMArrrr
�Comma,�r,cCr)zA period (.) leaf�.)rr�DOTrrrr
r&0r-r&cCs4ttj|��|��g�}|r|�dttj|��|S)z-A parenthesised argument list, used by Call()r)rrr%�clone�insert_child�arglist)�argsZlparenZrparen�noderrr
�ArgList4sr5cCs&ttj|t|�g�}|dur||_|S)zA function callN)rr�powerr5r)Z	func_namer3rr4rrr
�Call;sr7cCr)zA newline literal�
�rr�NEWLINErrrr
�NewlineBr-r;cCr)zA blank line�r9rrrr
�	BlankLineFr-r=cCr )Nr)rr�NUMBER)�nrrrr
�NumberJsr@cCs"ttjttjd�|ttjd�g�S)zA numeric or string subscript�[�])rrr%rr�LBRACE�RBRACE)Z
index_noderrr
�	SubscriptMs
�rEcCr )z
A string leafr)rr�STRING)�stringrrrr
�StringSr$rHc	Cs�d|_d|_d|_ttjd�}d|_ttjd�}d|_||||g}|r:d|_ttjd�}d|_|�ttj||g��ttj|ttj	|�g�}ttj
ttjd�|ttjd�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.
    r<r�for�in�ifrArB)
rrrr!�appendrrZcomp_ifZ	listmakerZcomp_forrrCrD)	Zxp�fp�it�testZfor_leafZin_leafZ
inner_argsZif_leaf�innerrrr
�ListCompWs(

��rQcCsV|D]}|��qttjd�ttj|dd�ttjddd�ttj|�g}ttj|�}|S)zO Return an import statement in the form:
        from package import name_leafs�fromrr�import)�removerrr!rr�import_as_names�import_from)Zpackage_nameZ
name_leafsZleaf�children�imprrr
�
FromImportos


�rYc	Cs�|d��}|jtjkr|��}n	ttj|��g�}|d}|r'dd�|D�}ttjtt|d�t|d��ttj|d��||d��g�g|�}|j	|_	|S)	zfReturns an import statement and calls a method
    of the module:

    import module
    module.name()r'�aftercSsg|]}|���qSr)r0)�.0r?rrr
�
<listcomp>�sz!ImportAndCall.<locals>.<listcomp>�rZlparZrpar)
r0�typerr2rr6r)r#r%r)r4�results�namesr'Z
newarglistrZ�newrrr
�
ImportAndCall�s*


�����rbcCs�t|t�r|jt�t�gkrdSt|t�oCt|j�dkoCt|jdt�oCt|jdt�oCt|jdt�oC|jdjdkoC|jdjdkS)z(Does the node represent a tuple literal?T�r]r�rr)rrrWrr�lenrr�r4rrr
�is_tuple�s
������rgcCsXt|t�o+t|j�dko+t|jdt�o+t|jdt�o+|jdjdko+|jdjdkS)z'Does the node represent a list literal?rr]���rArB)rrrerWrrrfrrr
�is_list�s
�����ricCsttjt�|t�g�S�N)rrrrrrfrrr
�parenthesize�srk>
�allr�max�set�any�min�tuple�sorted�sum�	enumerateccs,�t||�}|r|Vt||�}|sdSdS)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(�nextrrr
�
attr_chain�s�

�rwzefor_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*
>
FcCsptst�t�at�t�at�t�adatttg}t|t|d��D]\}}i}|�||�r5|d|ur5dSq dS)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�parentr4F)	�
pats_builtrZcompile_pattern�p0�p1�p2�ziprw�match)r4�patterns�patternrxr_rrr
�in_special_context�s



�r�cCs�|j}|dur|jtjkrdS|j}|jtjtjfvrdS|jtjkr,|j	d|ur,dS|jtj
ksI|jtjkrK|durB|jtjksI|j	d|urKdSdS)zG
    Check that something isn't an attribute or function name etc.
    NFr]T)
Zprev_siblingr^rr/rxr�funcdef�classdef�	expr_stmtrWZ
parametersZ
typedargslistr+)r4�prevrxrrr
�is_probably_builtin�sr�cCsP|dur&|jtjkrt|j�dkr|jd}|jtjkr|jS|j}|dusdS)zFind the indentation of *node*.Nrdrr<)	r^r�suitererWr�INDENTrrx)r4�indentrrr
�find_indentations
�r�cCs>|jtjkr|S|��}|jd}|_ttj|g�}||_|Srj)r^rr�r0rxr)r4rxr�rrr
�
make_suitesr�cCs.|jtjkr|j}|std��|jtjks|S)zFind the top level namespace.z,root found before file_input node was found.)r^rZ
file_inputrx�
ValueErrorrfrrr
�	find_root&s�r�cCst|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"r4Zbindingrrr
�does_tree_import/sr�cCs|jtjtjfvS)z0Returns true if the node is an import statement.)r^r�import_namerVrfrrr
�	is_import7sr�cCs*dd�}t|�}t|||�rdSd}}t|j�D]!\}}||�s"qt|j|d��D]
\}}||�s5nq+||}|dkrat|j�D]\}}|jtjkr`|jr`|jdjtjkr`|d}nqD|durxt	tj
ttjd�ttj|dd�g�}	nt
|ttj|dd�g�}	|	t�g}
|�|t	tj|
��dS)	z\ Works like `does_tree_import` but adds an import statement
        if it was not imported. cSs |jtjko|jot|jd�S)Nr])r^r�simple_stmtrWr�rfrrr
�is_import_stmt>s�z$touch_import.<locals>.is_import_stmtNr]rrSrr)r�r�rtrWr^rr�rrFrr�rr!rYr;r1)r�r"r4r��rootZ
insert_pos�offset�idxZnode2�import_rWrrr
�touch_import;s:��
�
r�cCs�|jD]�}d}|jtjkr)t||jd�r|St|t|jd�|�}|r(|}n�|jtjtjfvrBt|t|jd�|�}|rA|}nw|jtj	kr�t|t|jd�|�}|rX|}nat
|jdd��D] \}}|jtjkr�|j
dkr�t|t|j|d�|�}|r�|}qan6|jtvr�|jdj
|kr�|}n&t|||�r�|}n|jtjkr�t|||�}n|jtjkr�t||jd�r�|}|r�|s�|St|�r�|SqdS)	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.Nrrhrdrc�:�r])rWr^rZfor_stmt�_findr�r�Zif_stmtZ
while_stmtZtry_stmtrtr�COLONr�	_def_syms�_is_import_bindingr�r�r�)r"r4r��childZretr?�iZkidrrr
r�isL
�����r�cCsV|g}|r)|��}|jdkr|jtvr|�|j�n
|jtjkr'|j|kr'|S|sdS)N�)�popr^�_block_syms�extendrWrr!r)r"r4Znodesrrr
r��s�r�cCs�|jtjkrf|sf|jd}|jtjkr=|jD]$}|jtjkr+|jdj|kr*|Sq|jtjkr:|j|kr:|SqdS|jtjkrW|jd}|jtjkrU|j|krU|SdS|jtjkrd|j|krd|SdS|jtj	kr�|r{t
|jd���|kr{dS|jd}|r�td|�r�dS|jtj
kr�t||�r�|S|jtjkr�|jd}|jtjkr�|j|kr�|SdS|jtjkr�|j|kr�|S|r�|jtjkr�|SdS)z� Will return node if node will import name, or node
        will import * from package.  None is returned otherwise.
        See test cases for examples. rrdrhNrc�as)r^rr�rWZdotted_as_namesZdotted_as_namerrr!rV�str�stripr�rUZimport_as_name�STAR)r4r"r�rXr�Zlastr?rrr
r��sL

���
��

�r�rj)NN)6�__doc__Zpgen2rZpytreerrZpygramrrr<rrrrrr#r)r,r&r5r7r;r=r@rErHrQrYrbrgrirkZconsuming_callsrwrzr{r|ryr�r�r�r�r�r�r�r�r�r�r�r�r%r�r�r�rrrr
�<module>sZ




		-
*

Hacked By AnonymousFox1.0, Coded By AnonymousFox