403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.216.221
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/asttokens/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/asttokens/__pycache__/util.cpython-312.pyc
�

��ee�E��"�ddlZddlZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZmZmZddlmZerKddlmZGd�d	e
�ZeeefZej:dd
k(reeeeeefeeefefZ nej@Z d�Z!Gd�d
ejDd
d��Z#ej:dk\r
ejHZ%n
Gd�d�Z%d3d�Z&d3d�Z'ej:dk\rd�Z(nd�Z(d�Z)d�Z*d4d�Z+eejX�D��chc]Q\}}e-|e.�s�e/|ej`ejbejdejfejhf�r|��Sc}}Z5d4d�Z6eejX�D��chc]#\}}e-|e.�re/|ejn�r|��%c}}Z8eejX�D��chc]#\}}e-|e.�re/|ej�r|��%c}}hd�zZ9d�Z:d�Z;d�Z<d�Z=d �Z>d!�Z?d"�Z@eA�ZBd#�ZCd4d$�ZDd%�ZEGd&�d'eA�ZFej:dd
k(rd(�ZGnd)�ZGd*�ZHd+�ZIej:dd
d,k\rdd-lJmKZKeKd�.�d/��ZLd0�ZMyd1�ZLd2�ZMycc}}wcc}}wcc}}w)5�N)�ABCMeta)�Module�expr�AST)�Callable�Dict�Iterable�Iterator�List�Optional�Tuple�Union�cast�Any�
TYPE_CHECKING)�	iteritems�)�NodeNGc��eZdZdZdZdZy)�EnhancedASTNr)�__name__�
__module__�__qualname__�first_token�
last_token�lineno���0/usr/lib/python3/dist-packages/asttokens/util.pyrr!s���K��J�
�Frr�c�b�tj|�dt|�jd���S)zRReturns a human-friendly representation of a token with the given type and string.�:�u)�token�tok_name�repr�lstrip)�tok_type�strings  r�
token_reprr*/s'���N�N�8�,�d�6�l�.A�.A�#�.F�	G�Grc��eZdZdZd�Zy)�Tokena�
  TokenInfo is an 8-tuple containing the same 5 fields as the tokens produced by the tokenize
  module, and 3 additional ones useful for this module:

  - [0] .type     Token type (see token.py)
  - [1] .string   Token (a string)
  - [2] .start    Starting (row, column) indices of the token (a 2-tuple of ints)
  - [3] .end      Ending (row, column) indices of the token (a 2-tuple of ints)
  - [4] .line     Original line (string)
  - [5] .index    Index of the token in the list of tokens that it belongs to.
  - [6] .startpos Starting character offset into the input text.
  - [7] .endpos   Ending character offset into the input text.
  c�B�t|j|j�S�N)r*�typer)��selfs r�__str__z
Token.__str__Ds���d�i�i����-�-rN)rrr�__doc__r2rrrr,r,6s���.rr,z0type string start end line index startpos endpos)��c��eZdZe�Zy)�AstConstantN)rrr�object�valuerrrr7r7Ls	���H�Err7c�N�|j|k(xr|duxs|j|k(S)zVReturns true if token is of the given type and, if a string is given, has that string.N)r/r)�r$r(�tok_strs   r�match_tokenr=Ps*��
���x�	�	P�W��_�%O�����8O�Prc��t|||�sGtdt||��dt|��d|jd�d|jddz����y)z�
  Verifies that the given token is of the expected type. If tok_str is given, the token string
  is verified too. If the token doesn't match, raises an informative ValueError.
  zExpected token z, got z	 on line rz col rN)r=�
ValueErrorr*�str�startr;s   r�expect_tokenrBVsQ��
�U�H�g�	.�
���7�#�S��Z��k�k�!�n�e�k�k�!�n�q�(�*�+�+�
/r)r4�c�d�|tjtjtjfvS�zW
    These are considered non-coding tokens, as they don't affect the syntax tree.
    )r$�NL�COMMENT�ENCODING��
token_types r�is_non_coding_tokenrKds"��
�%�(�(�E�M�M�5�>�>�B�B�Brc�(�|tjk\SrE)r$�N_TOKENSrIs rrKrKks��
����'�'rc��tjttgtftj|�j��S)z;
  Generates standard library tokens for the given code.
  )�tokenize�generate_tokensrrr@�io�StringIO�readline)�texts rrPrPss4��
�	!�	!�$�x��C��'8�"�+�+�d�:K�:T�:T�"U�	V�Vrc�2�t|d�rtStS)z�
  Returns a function which yields all direct children of a AST node,
  skipping children that are singleton nodes.
  The function depends on whether ``node`` is from ``ast`` or from the ``astroid`` module.
  �get_children)�hasattr�iter_children_astroid�iter_children_ast��nodes r�iter_children_funcr\~s��#*�$��"?�	�V�EV�Vrc�@�|s
t|�rgS|j�Sr.)�
is_joined_strrV)r[�include_joined_strs  rrXrX�s ��	�
�d� 3�
�I�	
�	�	�	�rc#�$K�|st|�ryt|tj�r3t	|j
|j�D]\}}|�|��|���ytj|�D]}|jtvs�|���y�wr.)
r^�
isinstance�astr�zip�keys�values�iter_child_nodes�	__class__�
SINGLETONS)r[r_�keyr9�childs     rrYrY�s�����	�
�d� 3�
���c�h�h���D�I�I�t�{�{�3����e�	���	��k����#�#�D�)��e�
���j�(��k��s�BB�	B>�Const�DelAttr�DelName�
AssignAttr�
AssignNamec�:�|jjtvS)z+Returns whether node is an expression node.)rgr�expr_class_namesrZs r�is_exprrr����
���	 �	 �$4�	4�4rc�:�|jjtvS)z)Returns whether node is a statement node.)rgr�stmt_class_namesrZs r�is_stmtrv�rsrc�4�|jjdk(S)z&Returns whether node is a module node.r�rgrrZs r�	is_modulery�s��
���	 �	 �H�	,�,rc�4�|jjdk(S)zFReturns whether node is a JoinedStr node, used to represent f-strings.�	JoinedStrrxrZs rr^r^�s��

���	 �	 �K�	/�/rc�4�|jjdk(S)z2Returns whether node is a starred expression node.�StarredrxrZs r�
is_starredr~�s��
���	 �	 �I�	-�-rc	���|jjdvxsV|jjdk(xr;tttttj|�j��S)z?Returns whether node represents a slice, e.g. `1:2` in `x[1:2]`)�Slice�ExtSlicer
)	rgr�any�map�is_slicerrbr
�eltsrZs rr�r��sX���n�n���!6�6��
�.�.�
!�
!�W�
,�=��#�h��S�Y�Y�� 5� :� :�;�<�	rc���|jjdk(xrPt|tj�xr3|j
|jcxuxr|jcxuxrduScS)Nr�)rgrrarbr�lower�upper�steprZs r�is_empty_astroid_slicer��s^���n�n����(�8���s�w�w�'�
'�8�
�*�*��
�
�
7�d�i�i�
7�4�
7��8�rc��|sd�}t|�}t�}d}|dtfg}|r�|j�\}}}	|	turi||vsJ�|j	|�|||�\}
}|j|||f�t
|�}||�D]}
|j||
|
tf��n|||ttt|	��}|r��|S)a5
  Scans the tree under the node depth-first using an explicit stack. It avoids implicit recursion
  via the function call stack to avoid hitting 'maximum recursion depth exceeded' error.

  It calls ``previsit()`` and ``postvisit()`` as follows:

  * ``previsit(node, par_value)`` - should return ``(par_value, value)``
        ``par_value`` is as returned from ``previsit()`` of the parent.

  * ``postvisit(node, par_value, value)`` - should return ``value``
        ``par_value`` is as returned from ``previsit()`` of the parent, and ``value`` is as
        returned from ``previsit()`` of this node itself. The return ``value`` is ignored except
        the one for the root node, which is returned from the overall ``visit_tree()`` call.

  For the initial node, ``par_value`` is None. ``postvisit`` may be None.
  c��yr.r)r[�pvaluer9s   r�<lambda>zvisit_tree.<locals>.<lambda>�s�rN)r\�set�	_PREVISIT�pop�add�append�len�insertrrr,)r[�previsit�	postvisit�
iter_children�done�ret�stack�current�	par_valuer9r��
post_value�ins�ns              r�
visit_treer��s���$
�0�I�$�T�*�-�	��$��#��$�	�"�
#�%�
� %�	�	���G�Y���	��
�D�
 � �
 �
�h�h�w��#�G�Y�7��f�j��l�l�G�Y�
�3�4�
��J�c��W�%�2�!�
���S�1�f�i�0�1�2�
�g�y�$�x����*F�G�c�	�

�*rc#��K�t|�}t�}|g}|rZ|j�}||vsJ�|j|�|��t	|�}|||�D]}|j||��|r�Yyy�w)a1
  Recursively yield all descendant nodes in the tree starting at ``node`` (including ``node``
  itself), using depth-first pre-order traversal (yieling parents before their children).

  This is similar to ``ast.walk()``, but with a different order, and it works for both ``ast`` and
  ``astroid`` trees. Also, as ``iter_children()``, it skips singleton nodes generated by ``ast``.

  By default, ``JoinedStr`` (f-string) nodes and their contents are skipped
  because they previously couldn't be handled. Set ``include_joined_str`` to True to include them.
  N)r\r�r�r�r�r�)r[r_r�r�r�r�r��cs        r�walkr�s�����%�T�*�-�	��$��&�%�
��i�i�k�G��$�����H�H�W��
�M��e�*�C�
�7�$6�
7����l�l�3����	�s�A3A8�6A8c���d}g}t|�D]-\}}}|j|||�|j|�|}�/|j||d�dj|�S)ah
  Replaces multiple slices of text with new values. This is a convenience method for making code
  modifications of ranges e.g. as identified by ``ASTTokens.get_text_range(node)``. Replacements is
  an iterable of ``(start, end, new_text)`` tuples.

  For example, ``replace("this is a test", [(0, 4, "X"), (8, 9, "THE")])`` produces
  ``"X is THE test"``.
  rN�)�sortedr��join)rT�replacements�p�partsrA�end�new_texts       r�replacer�1sn���!�
�%� &�|� 4���u�c�8�	�L�L��a����	�L�L����A���,�,�t�A�B�x��	�����rc��eZdZdZd�Zd�Zy)�NodeMethodsz[
  Helper to get `visit_{node_type}` methods given a node's class and cache the results.
  c��i|_yr.)�_cacher0s r�__init__zNodeMethods.__init__Is	���D�Krc���|jj|�}|sCd|jj�z}t	|||j
�}||j|<|S)z�
    Using the lowercase name of the class as node_type, returns `obj.visit_{node_type}`,
    or `obj.visit_default` if the type-specific method is not found.
    �visit_)r��getrr��getattr�
visit_default)r1�obj�cls�method�names     rr�zNodeMethods.getMsW���[�[�_�_�S�
!�F��
����*�*�,�
,�d��s�D�#�"3�"3�4�f��d�k�k�#���MrN)rrrr3r�r�rrrr�r�Es����rr�c��t|�Sr.)�iter)�original_tokenss r�patched_generate_tokensr�^s
���� � rc#�PK�g}|D]�}|jtjtjtjfvr0|r|dj
|jk(r|j|��nt|�D]}|���g}|����t|�D]}|���y�w)a�
    Fixes tokens yielded by `tokenize.generate_tokens` to handle more non-ASCII characters in identifiers.
    Workaround for https://github.com/python/cpython/issues/68382.
    Should only be used when tokenizing a string that is known to be valid syntax,
    because it assumes that error tokens are not actually errors.
    Combines groups of consecutive NAME, NUMBER, and/or ERRORTOKEN tokens into a single NAME token.
    ���N)	r/rO�NAME�
ERRORTOKEN�NUMBERr�rAr��combine_tokens)r��group�tok�combined_tokens    rr�r�bs�����
�E����

�(�(�x�}�}�h�&9�&9�8�?�?�K�
K��E�"�I�M�M�S�Y�Y�6�
���S��,�U�3�	�N��
�	����	��)��/������s�B$B&c�L�td�|D��r&t|D�chc]}|j��c}�dk7r|Stjtj
dj
d�|D��|dj|dj|dj��gScc}w)Nc3�VK�|]!}|jtjk(���#y�wr.)r/rOr�)�.0r�s  r�	<genexpr>z!combine_tokens.<locals>.<genexpr>}s����@�3�s�x�x�8�.�.�.�@�s�')rr�c3�4K�|]}|j���y�wr.)r))r��ts  rr�z!combine_tokens.<locals>.<genexpr>�s����/�A�q�x�x�/�s�rr�)r/r)rAr��line)	r�r�r�rO�	TokenInfor�r�rAr�)r�r�s  rr�r�{s����@�%�@�@�C�]b�Hc�VY����Hc�Dd�hi�Di�
�l����
�]�]��w�w�/��/�/��A�h�n�n��"�I�M�M�
�1�X�]�]�����Ids�B!c��t|�|�D�cgc]&}t|�st|�jdvr|��(}}|rt	|d�S|Scc}w)zq
  If the given AST node contains multiple statements, return the last one.
  Otherwise, just return the node.
  )�
excepthandler�
ExceptHandler�
match_case�	MatchCase�	TryExcept�
TryFinallyr�)r\rvr/r�	last_stmt)r[rj�child_stmtss   rr�r��si��0�)�$�/��5�
���u�~��e��-�-�2��
�
�+�
���[��_�%�%�	
�+��
s�+A)r4�)�	lru_cache)�maxsizec�~��d�tj��}tj|�D�cgc]}t|tj�s�|��!}}|D�cgc]}|j
|jf��}}tt|��t|�k(}t�fd�|D��}|xr|Scc}wcc}w)a�
    The positions attached to nodes inside f-string FormattedValues have some bugs
    that were fixed in Python 3.9.7 in https://github.com/python/cpython/pull/27729.
    This checks for those bugs more concretely without relying on the Python version.
    Specifically this checks:
     - Values with a format spec or conversion
     - Repeated (i.e. identical-looking) expressions
     - f-strings implicitly concatenated over multiple lines.
     - Multiline, triple-quoted f-strings.
    z�(
      f"a {b}{b} c {d!r} e {f:g} h {i:{j}} k {l:{m:n}}"
      f"a {b}{b} c {d!r} e {f:g} h {i:{j}} k {l:{m:n}}"
      f"{x + y + z} {x} {y} {z} {z} {z!a} {z:z}"
      f'''
      {s} {t}
      {u} {v}
      '''
    )c3�d�K�|]'}tj�|�|jk(���)y�wr.)rb�get_source_segment�id)r�r[�sources  �rr�z)fstring_positions_work.<locals>.<genexpr>�s/�����"�
�
���V�T�*�d�g�g�5�"�s�-0)
rb�parser�ra�Namer�
col_offsetr�r��all)�treer[�
name_nodes�name_positions�positions_are_unique�correct_source_segmentsr�s      @r�fstring_positions_workr��s����	�F��9�9�V��D�#&�8�8�D�>�P�4�Z��c�h�h�5O�$�P�J�P�AK�L��t�{�{�D�O�O�4�L�N�L��s�>�2�3�s�>�7J�J��!�"��"��� �;�$;�;��Q��Ls�B5�B5�B:c��tjdk\ryt|d��D]�}t|tj
�s�|jD]}t|dd�t|tj�s�+t�s't|j�D]}t|dd��|js�it|jdd�����y)z
    Add a special attribute `_broken_positions` to nodes inside f-strings
    if the lineno/col_offset cannot be trusted.
    )r4�NT)r_�_broken_positions)�sys�version_infor�rarbr{re�setattr�FormattedValuer�r9�format_spec)r��	joinedstr�partrjs    r�annotate_fstring_nodesr��s������7�"�
��$�4�8�A�	�
�	�3�=�=�
1���"�"�A�$���)�4�0��d�C�.�.�/�'�)��d�j�j�)�
8���e�0�$�7�
8��
�
��D�$�$�&9�4�@�A�Arc��y)NFrrrrr�r��s��rc��yr.r)�_trees rr�r��s��rr.)F)Nrb�collectionsrQr�r$rO�abcrrrr�typingrrr	r
rrr
rrrr�sixr�astroid_compatrr�AstNoder��intr@r�r*�
namedtupler,�Constantr7r=rBrKrPr\rX�__dict__rar/�
issubclass�expr_context�boolop�operator�unaryop�cmpoprhrY�stmtrurqrrrvryr^r~r�r�r8r�r�r�r�r�r�r�r��	functoolsr�r�r�)r�r�s00r�<module>r
s�����	�
����!�!�m�m�m�m���$��C��
�+�v�%�&�'����a��A���c�3��c�3�h���s�C�x��#�E�F�I��"�"�I�H�.�"�K�"�"�7�,^�_�.�&���v�����+���Q�	+����v��C�(�W�W��&�c�l�l�3�c�D�A�q�z�!�T�7J���S�-�-�s�z�z�3�<�<����VY�V_�V_�`�a��c�
��,#,�C�L�L�"9�H�$�!�Q�!�!�T�*�z�!�S�X�X�/F��H��#,�S�\�\�#:�H�4�1�a�!�!�T�*�z�!�S�X�X�/F��H�O�P��5�
5�
-�
0�.���
�H�	�(
�V�:�(�&��,���A��!��!��2��,���B�Q��6�!�!��T��<��<�>A�6�	��e
c��4H��Hs�I?�*AI?�(J�(J

Youez - 2016 - github.com/yon3zu
LinuXploit