https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/libfuturize/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/libfuturize/__pycache__/fixer_util.cpython-310.pyc
o

,�]VD�@s\dZddlmZmZmZmZmZmZddlm	Z	m
Z
ddlmZ
mZddlmZddlm
Z
mZmZm
Z
mZmZddlZdd	�Zd4d
d�Zd4dd
�Zd4dd�Zdd�Zdd�Zdd�Zdd�Zd5dd�Ze
je
je
je
j e
j!fZ"e
j#e
j$fZ%dd�Z&d4dd�Z'dd�Z(d d!�Z)d"d#�Z*d$d%�Z+d&d'�Z,d(d)�Z-d*d+�Z.d,Z/d-Z0d.d/�Z1d0d1�Z2d4d2d3�Z3dS)6z�
Utility functions from 2to3, 3to2 and python-modernize (and some home-grown
ones).

Licences:
2to3: PSF License v2
3to2: Apache Software License (from 3to2/setup.py)
python-modernize licence: BSD (from python-modernize/LICENSE)
�)�
FromImport�Newline�	is_import�	find_root�does_tree_import�Comma)�Leaf�Node)�python_symbols�python_grammar)�token)r	�Call�Name�symsr�NumberNcsxd�vr�S��d�r�dd���fdd�|D�}t|�dkr.tdd	�d
d�|D����t|�dkr8td
��|dS)al
    Examples:
    >>> canonical_fix_name('fix_wrap_text_literals')
    'libfuturize.fixes.fix_wrap_text_literals'
    >>> canonical_fix_name('wrap_text_literals')
    'libfuturize.fixes.fix_wrap_text_literals'
    >>> canonical_fix_name('wrap_te')
    ValueError("unknown fixer name")
    >>> canonical_fix_name('wrap')
    ValueError("ambiguous fixer name")
    z.fix_�fix_�Ncs g|]}|�d����r|�qS)zfix_{0})�endswith�format)�.0�f��fix��8/usr/lib/python3/dist-packages/libfuturize/fixer_util.py�
<listcomp>(s
�z&canonical_fix_name.<locals>.<listcomp>�zOAmbiguous fixer name. Choose a fully qualified module name instead from these:
�
css�|]}d|VqdS)z  Nr)r�myfrrr�	<genexpr>-s�z%canonical_fix_name.<locals>.<genexpr>rz1Unknown fixer. Use --list-fixes or -l for a list.)�
startswith�len�
ValueError�join)r�avail_fixes�foundrrr�canonical_fix_names
�r&cC�ttjd|d�S)N�*��prefix)rr�STARr)rrr�Star6�r,cCr')Nz**r))rr�
DOUBLESTARr)rrr�
DoubleStar9r-r/cCr')N�-r))rr�MINUSr)rrr�Minus<r-r2cCs.g}|D]
}|�|�|�t��q|d=|S)z{
    Accepts/turns: (Name, Name, ..., Name, Name)
    Returns/into: (Name, Comma, Name, Comma, ..., Name, Comma, Name)
    ���)�appendr)�leafs�	new_leafs�leafrrr�	commatize?s
r8cCs�|jdur|jjtjkr|j}|jdur|jjtjks|jdur"dS|jtjkr+|jS|jdur;|jjtjkr;|jjS|jdurBdS|jS)zf
    Returns the indentation for this node
    Iff a node is in a suite, then it has indentation.
    N�)	�parent�typer�suiter�INDENT�value�prev_siblingr*��noderrr�indentationKs�

rBcCs.t|�}tdd�|��D��}|sdSt|�S)a
    Dirty little trick to get the difference between each indentation level
    Implemented by finding the shortest indentation string
    (technically, the "least" of all of the indentation strings, but
    tabs and spaces mixed won't get this far, so those are synonymous.)
    css"�|]}|jtjkr|jVqdS�N)r;rr=r>�r�irrrris� z#indentation_step.<locals>.<genexpr>z    )r�set�	pre_order�min)rA�r�all_indentsrrr�indentation_step`s
rKcCs�|jD]}|jtjkrdSqt|j�D]\}}|jtjkr nqtd��ttjt	�t
tjt|�t
|��g�}|j|d}|��d|_|�|�|�|�dS)zj
    Turn the stuff after the first colon in parent's children
    into a suite, if it wasn't already
    NzNo class suite and no ':'!rr9)�childrenr;rr<�	enumerater�COLONr"r	rrr=rBrK�remover*�append_child)r:rArEr<�one_noderrr�suitifyps
��&
rRcCsN|durd}td|d�|g}|dur!|�tddd�t|dd�g�ttj|�S)z�
    Accepts a package (Name node), name to import it as (string), and
    optional prefix and returns a node:
    import <package> [as <as_name>]
    Nr9�importr)�as� )r�extendr	r�import_name)�package�as_namer*rLrrr�
NameImport�s
�rZccs(�|jtvsJ�|j}|jtjkr'|j}|jtjkrn|V|j}|jtjks|j}|jtjks2J�|j}|durC|V|j}|dus9|j}|jt	vra|}|jdur^|jV|j}|jdusR|j}|j}|durjdS|jt	vr�|jtj
krx|V|j}|dur�|j}|j}|dur�dS|jt	vsodSdS)z�
    Generator yields all nodes for which a node (an import_stmt) has scope
    The purpose of this is for a call to _find() on each of them
    N)r;�
_import_stmts�next_siblingr�SEMI�NEWLINEr:r�simple_stmt�_compound_stmtsr<)rA�test�nxtr:�context�c�prrr�import_binding_scope�sL���


�
�rfcCsDt|�}tddd�}t|dd�}ttj|||g�}|dur ||_|S)NrTrUr))rr	r�import_as_namer*)�namerYr*�new_name�new_as�new_as_name�new_noderrr�ImportAsName�srmcCs,|jtjkot|j�dko|jdjtjkS)z<
    Returns True if the node appears to be a docstring
    r)r;rr_r!rLr�STRINGr@rrr�is_docstring�s
��rocCs�t|�}td||�rdSd}t|j�D]"\}}t|�st|�r!|}t|�r&qt|�}|s.n||vr5dSqtdt	t
j|dd�g�}|dkrW|dkrW|jdj|_d|jd_|t
�g}|�|ttj|��dS)z
    This seems to work
    �
__future__NrUr)rr9)rrrMrL�is_shebang_comment�is_encoding_commentro�check_future_importrrr�NAMEr*r�insert_childr	rr_)�featurerA�root�shebang_encoding_idx�idx�names�import_rLrrr�
future_import�s*�
r|c	Cs�t|�}td||�rdSd}t|j�D]\}}|jtjkr/|jr/|jdjtjkr/|d}nq|j|d�D]}|jtj	krD|d7}q7|j
}d|_
nd}tdttj
|dd�g�}|t�g}|�|ttj||d��dS)zD
    An alternative to future_import() which might not work ...
    rpNrrr9rUr))rrrMrLr;rr_rrnr^r*rrrtrrur	)	rvrArw�
insert_posry�thing_afterr*r{rLrrr�future_import2s*�
rcCs�dd�|D�}tdd�|D��}t|�D])\}}|jtjkr5|jdjtjkr5|jdj}|jd||<q||}|||<q|S)z/
    Parse a list of arguments into a dict
    cSsg|]
}|jtjkr|�qSr)r;r�COMMArDrrrr2szparse_args.<locals>.<listcomp>cSsg|]}|df�qSrCr)r�krrrr4srr�)	�dictrMr;r�argumentrLr�EQUALr>)�arglist�scheme�ret_mappingrE�arg�slotrrr�
parse_args.s
r�cCs |jtjko|jot|jd�S)Nr)r;rr_rLrr@rrr�is_import_stmtHs�r�cCst|�}t|||�rdSd}dD]}td||�rd}nq|rXd\}}t|j�D] \}}t|�rH|}|}	|rF|j}|	d7}	t|�sD|	}n|s6nq(|dusOJ�|dusUJ�|}
nt|j�D]\}}|jtjkrint	|�sonq]|}
|dur�t
tjtt
jd�tt
j|d	d
�g�}nFt|tt
j|d	d
�g�}|dkr�t
tjt
tjtt
jd�t
tjtt
jd�tt
jd
�g�t
tjtt
jd�tt
jd�g�g�g�}|t�g}
ng}
|t�g}|j|
j}d|j|
_|�|
t
tj||d
��t|
�dk�r|�|
dt
tj|
��dSdS)a�Works like `does_tree_import` but adds an import statement at the
    top if it was not imported (but below any __future__ imports) and below any
    comments such as shebang lines).

    Based on lib2to3.fixer_util.touch_import()

    Calling this multiple times adds the imports in reverse order.

    Also adds "standard_library.install_aliases()" after "from future import
    standard_library".  This should probably be factored into another function.
    NF)�absolute_import�division�print_function�unicode_literalsrpT�NNrrSrUr)�standard_library�.�install_aliases�(�)r9r)rrrMrLrsr\r;rr_ror	rWrrrtr�power�trailer�DOT�LPAR�RPARrr*rur!)rX�name_to_importrArwr%rh�start�endry�idx2r}r{�
install_hooks�children_hooks�children_import�
old_prefixrrr�touch_import_topMs|
����
�

�
����

�r�cCsD|}|jtjkr|jst�S|jd}|jtjkr)t|jdd�r)|jdjdks,t�S|jdjtj	kr;|jd}n|jd}|jtj
krwt�}|jD](}|jtjkr[|�|j�qL|jtj
krt|jd}|jtjksnJ�|�|j�qL|S|jtj
kr�|jd}|jtjks�J�t|jg�S|jtjkr�t|jg�SJd|��)	zZIf this is a future import, return set of symbols that are imported,
    else return None.rrr>rp�rFzstrange import: %s)r;rr_rLrF�import_from�hasattrr>rr��import_as_namesrt�addrg)rA�savenode�result�nrrrrs�s<
�


�
rsz^#!.*pythonz^#.*coding[:=]\s*([-\w.]+)cC�tt�t|j��S)z�
    Comments are prefixes for Leaf nodes. Returns whether the given node has a
    prefix that looks like a shebang line or an encoding line:

        #!/usr/bin/env python
        #!/usr/bin/python3
    )�bool�re�match�
SHEBANG_REGEXr*r@rrrrq�srqcCr�)a
    Comments are prefixes for Leaf nodes. Returns whether the given node has a
    prefix that looks like an encoding line:

        # coding: utf-8
        # encoding: utf-8
        # -*- coding: <encoding name> -*-
        # vim: set fileencoding=<encoding name> :
    )r�r�r��ENCODING_REGEXr*r@rrrrr�s
rrcCsHt|�dksJ�t|�dkr|\}}|t�|g}n|}tt|�||d�S)z�
    Example:
    >>> wrap_in_fn_call("oldstr", (arg,))
    oldstr(arg)

    >>> wrap_in_fn_call("olddiv", (arg1, arg2))
    olddiv(arg1, arg2)

    >>> wrap_in_fn_call("olddiv", [arg1, comma, arg2, comma, arg3])
    olddiv(arg1, arg2, arg3)
    rr�r))r!rr
r)�fn_name�argsr*�expr1�expr2�newargsrrr�wrap_in_fn_call�sr�rCr�)4�__doc__�lib2to3.fixer_utilrrrrrr�lib2to3.pytreerr	�lib2to3.pygramr
rrrr
rrr�r&r,r/r2r8rBrKrRrZ�if_stmt�
while_stmt�for_stmt�try_stmt�	with_stmtr`rWr�r[rfrmror|rr�r�r�rsr�r�rqrrr�rrrr�<module>s@ 
 
"



;
( c*

https://t.me/RX1948 - 2025