403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.216.52
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/parso/python/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/parso/python/__pycache__/tree.cpython-312.pyc
�

̑�aC����dZddlZ	ddlmZddlmZddlm	Z	m
Z
mZmZm
Z
mZddlmZddlmZegd��Zed	d
g�ezZegd��ezZegd��Zed
dg�ZGd�d�ZGd�d�ZGd�dee�ZGd�de�ZGd�dee
�ZGd�dee	�ZGd�dee�ZGd�de
e�Z Gd�d e�Z!Gd!�d"e�Z"Gd#�d$e�Z#Gd%�d&e�Z$Gd'�d(e$�Z%Gd)�d*e$�Z&Gd+�d,e�Z'Gd-�d.e�Z(Gd/�d0e�Z)Gd1�d2�Z*Gd3�d4ee*�Z+Gd5�d6ee*�Z,Gd7�d8ee�Z-Gd9�d:e-�Z.Gd;�d<e�Z/Gd=�d>e-�Z0Gd?�d@e0�Z1dA�Z2GdB�dCe0�Z3GdD�dEe3�Z4GdF�dGe�Z5GdH�dIe5�Z6GdJ�dKe5�Z7GdL�dMe5�Z8GdN�dOe5�Z9GdP�dQe5�Z:GdR�dSe�Z;GdT�dUe;�Z<GdV�dWe;�Z=GdX�dYe�Z>GdZ�d[e>�Z?Gd\�d]e>�Z@Gd^�d_e>�ZAGd`�dae�ZBdb�ZCGdc�ddee�ZDGde�dfe�ZEGdg�dhe�ZFGdi�dje�ZGeGZHGdk�dle�ZIy#e$r
ddlmZY��qwxYw)ma
This is the syntax tree for Python 3 syntaxes. The classes represent
syntax elements like functions and imports.

All of the nodes can be traced back to the `Python grammar file
<https://docs.python.org/3/reference/grammar.html>`_. If you want to know how
a tree is structured, just analyse that file (for each Python version it's a
bit different).

There's a lot of logic here that makes it easier for Jedi (and other libraries)
to deal with a Python syntax tree.

By using :py:meth:`parso.tree.NodeOrLeaf.get_code` on a module, you can get
back the 1-to-1 representation of the input given to the parser. This is
important if you want to refactor a parser tree.

>>> from parso import parse
>>> parser = parse('import os')
>>> module = parser.get_root_node()
>>> module
<Module: @1-1>

Any subclasses of :class:`Scope`, including :class:`Module` has an attribute
:attr:`iter_imports <Scope.iter_imports>`:

>>> list(module.iter_imports())
[<ImportName: import os@1,0>]

Changes to the Python Grammar
-----------------------------

A few things have changed when looking at Python grammar files:

- :class:`Param` does not exist in Python grammar files. It is essentially a
  part of a ``parameters`` node.  |parso| splits it up to make it easier to
  analyse parameters. However this just makes it easier to deal with the syntax
  tree, it doesn't actually change the valid syntax.
- A few nodes like `lambdef` and `lambdef_nocond` have been merged in the
  syntax tree to make it easier to do deal with them.

Parser Tree Classes
-------------------
�N)�Mapping)�Tuple)�Node�BaseNode�Leaf�	ErrorNode�	ErrorLeaf�search_ancestor)�split_prefix)�split_lines)�if_stmt�
while_stmt�for_stmt�try_stmt�	with_stmt�
async_stmt�suiter�simple_stmt)rr�	decorated�
async_funcdef)	�	expr_stmt�
sync_comp_forrr�import_name�import_from�param�del_stmt�namedexpr_testrrc��eZdZdZd�Zy)�DocstringMixin�c���|jdk(r|jd}n�|jdvrJ|j|jjd�dz}|jdk(rN|jd}n>|j}|jj}|j|�}|sy||dz
}|jdk(r|jd}|jd	k(r|Sy)
zN
        Returns the string leaf of a docstring. e.g. ``r'''foo'''``.
        �
file_inputr��funcdef�classdef�:�rNr�string)�type�children�index�parent)�self�noder�cr+s     �3/usr/lib/python3/dist-packages/parso/python/tree.py�get_doc_nodezDocstringMixin.get_doc_nodeJs����9�9��$��=�=��#�D�
�Y�Y�1�
1��=�=����!4�!4�S�!9�A�!=�>�D��y�y�G�#��}�}�Q�'���+�+�K��"�"�+�+�A��G�G�K�(�E����U�Q�Y�<�D��9�9�
�%��=�=��#�D��9�9�� ��K��N)�__name__�
__module__�__qualname__�	__slots__r1r r2r0rrGs���I�r2rc��eZdZdZdZd�Zy)�PythonMixinz)
    Some Python specific utilities.
    r c���|jD]_}t|t�r6|jdk(s�#|j|cxkr|j
ks�C|cS�I|j
|�}|��]|cSy)z�
        Given a (line, column) tuple, returns a :py:class:`Name` or ``None`` if
        there is no name at that position.
        �nameN)r*�
isinstancerr)�	start_pos�end_pos�get_name_of_position)r-�positionr/�results    r0r>z PythonMixin.get_name_of_positionisn��
���	"�A��!�T�"��6�6�V�#����x�(L�1�9�9�(L��H�)M��/�/��9���%�!�M�	"�r2N)r3r4r5�__doc__r6r>r r2r0r8r8cs����I�
r2r8c��eZdZdZd�Zd�Zy)�
PythonLeafr c�6�t||j��S�N)r�get_start_pos_of_prefix�r-s r0�
_split_prefixzPythonLeaf._split_prefix|s���D�$�">�">�"@�A�Ar2c��|j�}|�-|jdk(r|jdvr|j�}|�2t|j�}|j
t
|�z
dzdfS|jS)z[
        Basically calls :py:meth:`parso.tree.NodeOrLeaf.get_start_pos_of_prefix`.
        �
error_leaf)�INDENT�DEDENT�ERROR_DEDENTr'r)�get_previous_leafr)�
token_typer�prefix�line�lenr=)r-�
previous_leaf�liness   r0rFz"PythonLeaf.get_start_pos_of_prefixs���.�.�0�
��$��);�);�|�)K�!�,�,�0T�T�)�;�;�=�M�� �����,�E��9�9�s�5�z�)�A�-�q�0�0��$�$�$r2N)r3r4r5r6rHrFr r2r0rCrCys���I�B�%r2rCc�4�eZdZdZdZedeeeffd��Zy)�_LeafWithoutNewlinesz.
    Simply here to optimize performance.
    r �returnc�^�|j|jt|j�zfSrE)rQ�columnrR�valuerGs r0r=z_LeafWithoutNewlines.end_pos�s"���y�y�$�+�+��D�J�J��7�7�7r2N)	r3r4r5rAr6�propertyr�intr=r r2r0rVrV�s/����I�
�8��s�C�x��8��8r2rVc��eZdZdZy)�PythonBaseNoder N�r3r4r5r6r r2r0r^r^�����Ir2r^c��eZdZdZy)�
PythonNoder Nr_r r2r0rbrb�r`r2rbc��eZdZdZy)�PythonErrorNoder Nr_r r2r0rdrd�r`r2rdc��eZdZdZy)�PythonErrorLeafr Nr_r r2r0rfrf�r`r2rfc��eZdZdZdZd�Zy)�	EndMarkerr �	endmarkerc�z�dt|�j�dt|j��d|j�d�S)N�<z	: prefix=z	 end_pos=�>)r)r3�reprrPr=rGs r0�__repr__zEndMarker.__repr__�s*����J����d�k�k�!2�D�L�L�
�	
r2N)r3r4r5r6r)rnr r2r0rhrh�s���I��D�
r2rhc��eZdZdZdZdZd�Zy)�Newlinez&Contains NEWLINE and ENDMARKER tokens.r �newlinec�`�dt|�j�dt|j��d�S)Nrk�: rl)r)r3rmrZrGs r0rnzNewline.__repr__�s ��!�$�Z�0�0�$�t�z�z�2B�C�Cr2N)r3r4r5rAr6r)rnr r2r0rprp�s��0��I��D�Dr2rpc�.�eZdZdZdZdZd�Zdd�Zd	d�Zy)
�Nameza
    A string. Sometimes it is important to know if the string belongs to a name
    or not.
    r:r c	��dt|�j�d|j�d|j�d|j�d�	S)Nrkrs�@�,rl)r)r3rZrQrYrGs r0rnz
Name.__repr__�s,��#'��:�#6�#6��
�
�#'�9�9�d�k�k�;�	;r2c�*�|j|��duS)z<
        Returns True if the name is being defined.
        )�include_setitemN)�get_definition�r-rzs  r0�
is_definitionzName.is_definition�s���"�"�?�"�C�4�O�Or2c�h�|j}|j}|dvr||jk(r|Sy|dk(r |j�dk(r|jSy|�]|jdk(ry|jtvr,||j|�vr|S|r|jtvr|Sy|j}|��]y)z�
        Returns None if there's no definition for a name.

        :param import_name_always: Specifies if an import name is always a
            definition. Normally foo in `from foo import bar` is not a
            definition.
        r#N�
except_clause�asr)r,r)r:�get_previous_sibling�_GET_DEFINITION_TYPES�get_defined_names�_IMPORTS)r-�import_name_alwaysrzr.�type_s     r0r{zName.get_definition�s����{�{���	�	���+�+��t�y�y� �����O�#��(�(�*�d�2��{�{�"�����y�y�G�#���y�y�1�1��4�1�1�/�B�B��K�%�$�)�)�x�*?��K���;�;�D���r2N�F)FF)	r3r4r5rAr)r6rnr}r{r r2r0ruru�s#����D��I�;�P�r2ruc��eZdZdZy)�Literalr Nr_r r2r0r�r��r`r2r�c��eZdZdZdZy)�Number�numberr N�r3r4r5r)r6r r2r0r�r��s���D��Ir2r�c�*�eZdZdZdZed��Zd�Zy)�Stringr(r c�`�tjd|j�jd�S)Nz\w*(?=[\'"])r)�re�matchrZ�grouprGs r0�
string_prefixzString.string_prefixs"���x�x�����4�:�:�1�=�=r2c��tjd|jtj��}|j	d�dt|j	d��S)Nz('{3}|"{3}|'|")(.*)$)�flags�r')r��searchrZ�DOTALLr�rR)r-r�s  r0�_get_payloadzString._get_payloadsI���	�	�'��J�J��)�)�
��
�{�{�1�~�3��E�K�K��N� 3�3�4�4r2N)r3r4r5r)r6r[r�r�r r2r0r�r��s#���D��I�
�>��>�5r2r�c��eZdZdZdZdZy)�
FStringString�x
    f-strings contain f-string expressions and normal python strings. These are
    the string parts of f-strings.
    �fstring_stringr N�r3r4r5rAr)r6r r2r0r�r�s����D��Ir2r�c��eZdZdZdZdZy)�FStringStartr��
fstring_startr Nr�r r2r0r�r�s����D��Ir2r�c��eZdZdZdZdZy)�
FStringEndr��fstring_endr Nr�r r2r0r�r� s����D��Ir2r�c��eZdZd�Zd�Zy)�_StringComparisonMixinc�H�t|t�r|j|k(S||uS)ze
        Make comparisons with strings easy.
        Improves the readability of the parser.
        )r;�strrZ�r-�others  r0�__eq__z_StringComparisonMixin.__eq__*s'��
�e�S�!��:�:��&�&��u�}�r2c�,�t|j�SrE)�hashrZrGs r0�__hash__z_StringComparisonMixin.__hash__4����D�J�J��r2N)r3r4r5r�r�r r2r0r�r�)s��� r2r�c��eZdZdZdZy)�Operator�operatorr Nr�r r2r0r�r�8s���D��Ir2r�c��eZdZdZdZy)�Keyword�keywordr Nr�r r2r0r�r�=s���D��Ir2r�c�J��eZdZdZdZ�fd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Z�xZS)
�Scopez�
    Super class for the parser tree, which represents the state of a python
    text file.
    A Scope is either a function, class or lambda.
    r c�$��t�|�|�yrE��super�__init__�r-r*�	__class__s  �r0r�zScope.__init__J����
����"r2c�$�|jd�S)z9
        Returns a generator of `funcdef` nodes.
        r$��_search_in_scoperGs r0�
iter_funcdefszScope.iter_funcdefsMs���$�$�Y�/�/r2c�$�|jd�S)z:
        Returns a generator of `classdef` nodes.
        r%r�rGs r0�iter_classdefszScope.iter_classdefsSs���$�$�Z�0�0r2c�&�|jdd�S)zO
        Returns a generator of `import_name` and `import_from` nodes.
        rrr�rGs r0�iter_importszScope.iter_importsYs���$�$�]�M�B�Br2c�6�����fd���|j�S)Nc3��K�|D]A}|j�vr|��|jtvs�(�|j�Ed{����Cy7��wrE)r)�_FUNC_CONTAINERSr*)r*�element�names�scans  ��r0r�z$Scope._search_in_scope.<locals>.scan`sM�����#�
6���<�<�5�(�!�M��<�<�#3�3�#�G�$4�$4�5�5�5�	
6�6�s�*A
�A
�A�A
�r*)r-r�r�s `@r0r�zScope._search_in_scope_s���	6��D�M�M�"�"r2c� �|jdS)zD
        Returns the part that is executed by the function.
        ���r�rGs r0�	get_suitezScope.get_suiteis���}�}�R� � r2c	���	|jj}dt|�j�d|�d|j
d�d|jd�d�	S#t$rd}Y�IwxYw)N�rkrsrwr�-rl)r:rZ�AttributeErrorr)r3r<r=)r-r:s  r0rnzScope.__repr__os^��	��9�9�?�?�D��$(��:�#6�#6��#'�>�>�!�#4�d�l�l�1�o�G�	G���	��D�	�s�A�A"�!A")
r3r4r5rAr6r�r�r�r�r�r�rn�
__classcell__�r�s@r0r�r�Bs4����
�I�#�0�1�C�#�!�Gr2r�c�6��eZdZdZdZdZ�fd�Zd�Zd�Z�xZ	S)�Modulez�
    The top scope, which is always a module.
    Depending on the underlying parser this may be a full module or just a part
    of a module.
    )�_used_namesr"c�2��t�|�|�d|_yrE)r�r�r�r�s  �r0r�zModule.__init__�s���
����"���r2c#�K�|j�D]o}|jdk(s�|jdk(s�#|j�D]:}|D�cgc]}|j��}}t|�dk(s�+|ddk(s�4|d���<�qycc}w�w)zU
        :return: A list of future import names.
        :rtype: list of str
        rrr��
__future__r'N)r�r)�level�	get_pathsrZrR)r-�imp�pathr:r�s     r0�_iter_future_import_namesz Module._iter_future_import_names�s������$�$�&�	'�C��x�x�=�(�S�Y�Y�!�^��M�M�O�'�D�48�9�D�T�Z�Z�9�E�9��5�z�Q��5��8�|�+C�#�A�h��'�	'��:�s'�#B�B�B�
B� B�1B�:Bc�v���|j� i���fd���|�t��|_|jS)z�
        Returns all the :class:`Name` leafs that exist in this module. This
        includes both definitions and references of names.
        c����	|j}|D]
}�|��y#t$rA|jdk(r/�j|jg�}|j|�YyYywxYw)Nr:)r*r�r)�
setdefaultrZ�append)r.r*�child�arr�dct�recurses    ��r0r�z&Module.get_used_names.<locals>.recurse�sk���'�#�}�}�H�"*�'�����'��&�)��y�y�F�*�!�n�n�T�Z�Z��<���
�
�4�(�+�)�s��AA)�(A))r��UsedNamesMapping)r-r�r�s @@r0�get_used_nameszModule.get_used_names�s=���
���#��C�	
'�
�D�M�/��4�D�����r2)
r3r4r5rAr6r)r�r�r�r�r�s@r0r�r�ys#����
!�I��D� �'�  r2r�c��eZdZdZdZy)�	Decorator�	decoratorr Nr�r r2r0r�r��s���D��Ir2r�c�&�eZdZdZed��Zd�Zy)�ClassOrFuncr c� �|jdS)zR
        Returns the `Name` leaf that defines the function or class name.
        r'r�rGs r0r:zClassOrFunc.name�s��
�}�}�Q��r2c��|j}|jdk(r|j}|jdk(rD|jdjdk(r|jdjS|jddSgS)z4
        :rtype: list of :class:`Decorator`
        rrr�
decoratorsNr')r,r)r*)r-rs  r0�get_decoratorszClassOrFunc.get_decorators�sx���K�K�	��>�>�_�,�!�(�(�I��>�>�[�(��!�!�!�$�)�)�\�9� �)�)�!�,�5�5�5� �)�)�"�1�-�-��Ir2N)r3r4r5r6r[r:r�r r2r0r�r��s���I�
� �� �r2r�c�0��eZdZdZdZdZ�fd�Zd�Z�xZS)�Classz>
    Used to store the parsed contents of a python class.
    r%r c�$��t�|�|�yrEr�r�s  �r0r�zClass.__init__�r�r2c�l�|jddk7ry|jddk(ry|jdS)z
        Returns the `arglist` node that defines the super classes. It returns
        None if there are no arguments.
        r��(N��)r�rGs r0�get_super_arglistzClass.get_super_arglist�s;��
�=�=���s�"���}�}�Q��3�&���}�}�Q�'�'r2)	r3r4r5rAr)r6r�r�r�r�s@r0r�r��s�����D��I�#�(r2r�c��	|d}|jdvrt|g|�gS|dk(r|gS|jdk(r|g}n|j}g}d}t	|dgzd�D]l\}}|�|dk(s�|||}|s�|ddk(rt|�dk(s|ddk(s|ddk(r|D]	}	||	_�||z
}n|jt||��|}�n|S#t$rgcYSwxYw)	a�
    `argslist_list` is a list that can contain an argslist as a first item, but
    most not. It's basically the items between the parameter brackets (which is
    at most one item).
    This function modifies the parser structure. It generates `Param` objects
    from the normal ast. Those param objects do not exist in a normal ast, but
    make the evaluation of the ast tree so much easier.
    You could also say that this function replaces the argslist node with a
    list of Param objects.
    r)r:�fpdef�*�tfpdefNr'rx�/)�
IndexErrorr)�Paramr*�	enumeraterRr,r�)
r,�
argslist_list�firstr*�new_children�start�endr��param_children�ps
          r0�_create_paramsr
�s-����a� ��
�z�z�&�&��u�g�v�&�'�'�	�#���w���:�:��!��w�H��~�~�H�����#�H��v�$5�q�9�
	 �J�C���}����!)�%��!4��!�%�a�(�C�/�!$�^�!4��!9�$2�1�$5��$<�-�a�0�C�7�!/�.�A�'-�A�H�.�$��6��$�+�+�E�.�&�,I�J��E�
	 ����;���	��s�C�C�Cc�j��eZdZdZdZ�fd�Zd�Zd�Zed��Z	d�Z
d�Zd	�Zd
�Z
ed��Z�xZS)�Functionan
    Used to store the parsed contents of a python function.

    Children::

        0. <Keyword: def>
        1. <Name>
        2. parameter list (including open-paren and close-paren <Operator>s)
        3. or 5. <Operator: :>
        4. or 6. Node() representing function body
        3. -> (if annotation is also present)
        4. annotation (if present)
    r$c���t�|�|�|jd}|jdd}td�|D��st	||�|jddyy)Nr�r'r�c3�<K�|]}t|t����y�wrE�r;r��.0r�s  r0�	<genexpr>z$Function.__init__.<locals>.<genexpr>*�����M��:�e�U�+�M���)r�r�r*�anyr
)r-r*�
parameters�parameters_childrenr�s    �r0r�zFunction.__init__$sb���
����"��]�]�1�%�
�(�1�1�!�B�7���M�9L�M�M�(6�z�CV�(W�J����"�%�Nr2c�4�|jdjS)Nr�r�rGs r0�_get_param_nodeszFunction._get_param_nodes-s���}�}�Q��(�(�(r2c�h�|j�D�cgc]}|jdk(s�|��c}Scc}w)z.
        Returns a list of `Param()`.
        r)rr))r-rs  r0�
get_paramszFunction.get_params0s,�� �0�0�2�H�a�a�f�f��6G��H�H��Hs�/�/c� �|jdS�Nr'r�rGs r0r:z
Function.name6����}�}�Q��r2c�2���fd���|j�S)z6
        Returns a generator of `yield_expr`.
        c3��K�|D].}|jdvr�	|j}�|�Ed{����0y7�#t$r>|jdk(r,|jjdk(r|j��n|��Y�zwxYw�w)N)r%r$�lambdef�yield�
yield_expr)r)r*r�rZr,)r*r��nested_childrenr�s   �r0r�z'Function.iter_yield_exprs.<locals>.scan>s������#�

5���<�<�#E�E��	5�&-�&6�&6�O� $�O�4�4�4�

5�5��&�*��}�}��/�"�>�>�.�.�,�>�")�.�.�0�")�M��*�s/�B�:�B�8�B�AB�>B�B�Br��r-r�s @r0�iter_yield_exprszFunction.iter_yield_exprs:s���	5� �D�M�M�"�"r2c�2���fd���|j�S)z7
        Returns a generator of `return_stmt`.
        c3���K�|D]`}|jdk(s|jdk(r|jdk(r|��|jtvs�G�|j�Ed{����by7��w)N�return_stmtr�rW�r)rZ�_RETURN_STMT_CONTAINERSr*�r*r�r�s  �r0r�z(Function.iter_return_stmts.<locals>.scanTsd�����#�
6���<�<�=�0�"�<�<�9�4����(�9R�!�M��<�<�#:�:�#�G�$4�$4�5�5�5�
6�
6���A	A,�
A,�"A*�#A,r�r(s @r0�iter_return_stmtszFunction.iter_return_stmtsP����	6��D�M�M�"�"r2c�2���fd���|j�S)zi
        Returns a generator of `raise_stmt`. Includes raise statements inside try-except blocks
        c3���K�|D]`}|jdk(s|jdk(r|jdk(r|��|jtvs�G�|j�Ed{����by7��w)N�
raise_stmtr��raiser-r/s  �r0r�z'Function.iter_raise_stmts.<locals>.scanbsd�����#�
6���<�<�<�/�"�<�<�9�4����'�9Q�!�M��<�<�#:�:�#�G�$4�$4�5�5�5�
6�
6�r0r�r(s @r0�iter_raise_stmtszFunction.iter_raise_stmts^r2r2c�:�t|j�d�duS)zK
        :return bool: Checks if a function is a generator or not.
        N)�nextr)rGs r0�is_generatorzFunction.is_generatorls���D�)�)�+�T�2�$�>�>r2c��	|jddk(r|jdS|jddk(sJ�y#t$rYywxYw)zW
        Returns the test node after `->` or `None` if there is no annotation.
        r�z->�r&N)r*rrGs r0�
annotationzFunction.annotationrsS��
	��}�}�Q��4�'��}�}�Q�'�'��=�=��#�s�*�*�*����	��	�s� 8�8�	A�A)r3r4r5rAr)r�rrr[r:r)r1r7r:r=r�r�s@r0rrs\�����D�X�)�I�� �� �#�,#�#�?��
��
r2rc�V��eZdZdZdZdZ�fd�Zed��Zd�Z	ed��Z
d�Z�xZS)	�Lambdaz�
    Lambdas are basically trimmed functions, so give it the same interface.

    Children::

         0. <Keyword: lambda>
         *. <Param x> for each argument x
        -2. <Operator: :>
        -1. Node() representing body
    r$r c���tt|�|�|jdd}t	d�|D��st||�|jddyy)Nr'���c3�<K�|]}t|t����y�wrErrs  r0rz"Lambda.__init__.<locals>.<genexpr>�rr)r�rr�r*rr
)r-r*rr�s   �r0r�zLambda.__init__�sR���
�h��&�x�0�"�m�m�A�b�1���M�9L�M�M�"0��7J�"K�D�M�M�!�B��Nr2c��td��)zN
        Raises an AttributeError. Lambdas don't have a defined name.
        zlambda is not named.)r�rGs r0r:zLambda.name�s��
�3�4�4r2c� �|jddS)Nr'rAr�rGs r0rzLambda._get_param_nodes�s���}�}�Q�r�"�"r2c��y)zA
        Returns `None`, lambdas don't have annotations.
        Nr rGs r0r=zLambda.annotation�s��
r2c�P�d|jj�d|j�d�S)Nrkrwrl)r�r3r<rGs r0rnzLambda.__repr__�s�� �N�N�3�3�T�^�^�D�Dr2)
r3r4r5rAr)r6r�r[r:rr=rnr�r�s@r0r?r?�sM���	��D��I�L��5��5�#�����Er2r?c��eZdZdZy)�Flowr Nr_r r2r0rHrH�r`r2rHc�&�eZdZdZdZd�Zd�Zd�Zy)�IfStmtr
r c#�xK�t|j�D]\}}|dvs�|j|dz��� y�w)z�
        E.g. returns all the `test` nodes that are named as x, below:

            if x:
                pass
            elif x:
                pass
        )�elif�ifr'N)rr*)r-�ir/s   r0�get_test_nodeszIfStmt.get_test_nodes�s?�����d�m�m�,�	+�D�A�q��N�"��m�m�A��E�*�*�	+�s� :�:c��|j}tt|j���D]&}|j|ks�||jkry|cSy)z�
        Searches for the branch in which the node is and returns the
        corresponding test node (see function above). However if the node is in
        the test node itself and not in the suite return None.
        N)r<�reversed�listrOr=)r-r.r<�
check_nodes    r0�get_corresponding_test_nodez"IfStmt.get_corresponding_test_node�sV���N�N�	�"�4��(;�(;�(=�#>�?�	&�J��#�#�i�/��z�1�1�1��&�%�	&r2c�h�|jD]#}|dk(s�	|j|jkDs�#yy)z;
        Checks if a node is defined after `else`.
        �elseTF)r*r<)r-r.r/s   r0�is_node_after_elsezIfStmt.is_node_after_else�s6�����	�A��F�{��>�>�A�K�K�/��	�
r2N)r3r4r5r)r6rOrTrWr r2r0rJrJ�s���D��I�+�&� 	r2rJc��eZdZdZdZy)�	WhileStmtrr Nr�r r2r0rYrY�����D��Ir2rYc�"�eZdZdZdZd�Zdd�Zy)�ForStmtrr c� �|jdS)zE
        Returns the input node ``y`` from: ``for x in y:``.
        r�r�rGs r0�get_testlistzForStmt.get_testlist�s���}�}�Q��r2c�4�t|jd|�Sr ��_defined_namesr*r|s  r0r�zForStmt.get_defined_names�����d�m�m�A�.��@�@r2Nr�)r3r4r5r)r6r^r�r r2r0r\r\�s���D��I� �Ar2r\c��eZdZdZdZd�Zy)�TryStmtrr c#�K�|jD]-}|jdk(r|jd���$|dk(s�*d���/y�w)z�
        Returns the ``test`` nodes found in ``except_clause`` nodes.
        Returns ``[None]`` for except clauses without an exception given.
        rr'�exceptN�r*r)�r-r.s  r0�get_except_clause_testszTryStmt.get_except_clause_tests�sC����
�M�M�	�D��y�y�O�+��m�m�A�&�&���!��
�		�s
�6A�AN)r3r4r5r)r6rir r2r0rdrd�s���D��I�	r2rdc�"�eZdZdZdZdd�Zd�Zy)�WithStmtrr c��g}|jddd�D].}|jdk(s�|t|jd|�z
}�0|S)z}
        Returns the a list of `Name` that the with statement defines. The
        defined names are set after `as`.
        r'rAr��	with_item)r*r)ra)r-rzr�rms    r0r�zWithStmt.get_defined_namessX��
�����q��A�v�.�	P�I��~�~��,���	�(:�(:�1�(=��O�O��	P��r2c�\�|jd�}|�td��|jdS)Nrmz2The name is not actually part of a with statement.r)r
�
ValueErrorr*)r-r:r.s   r0�get_test_node_from_namez WithStmt.get_test_node_from_names2���#�#�K�0���<��Q�R�R��}�}�Q��r2Nr�)r3r4r5r)r6r�rpr r2r0rkrks���D��I�
� r2rkc�"�eZdZdZd�Zd�Zd�Zy)�Importr c���	|j�|}|j�D]}||vs�|d|j|�dzcSt	d��#t$rY�HwxYw)zo
        The path is the list of names that leads to the searched name.

        :return list of Name:
        Nr'z+Name should be defined in the import itself)�_aliases�KeyErrorr�r+ro)r-r:r�s   r0�get_path_for_namezImport.get_path_for_namest��	��=�=�?�4�(�D��N�N�$�	3�D��t�|��1�T�Z�Z��-��1�2�2�	3��F�G�G��
�	��	�s�A�	A�Ac��y)NFr rGs r0�	is_nestedzImport.is_nested,s��r2c�&�|jddk(S)Nr�rr�rGs r0�is_star_importzImport.is_star_import/s���}�}�R� �C�'�'r2N)r3r4r5r6rvrxrzr r2r0rrrrs���I�H�"�(r2rrc�D�eZdZdZdZd
d�Zd�Zd�Zed��Z	d�Z
d�Zy	)�
ImportFromrr c�\�|j�D��cgc]\}}|xs|��
c}}Scc}}w)z�
        Returns the a list of `Name` that the import defines. The
        defined names are set after `import` or in case an alias - `as` - is
        present that name is returned.
        )�_as_name_tuples)r-rzr:�aliass    r0r�zImportFrom.get_defined_names7s+��26�1E�1E�1G�H�+�$���
��
�H�H��Hs�(c�B�td�|j�D��S)z-Mapping from alias to its corresponding name.c3�.K�|]
\}}|�||f���y�wrEr )rr:rs   r0rz&ImportFrom._aliases.<locals>.<genexpr>As%����*�k�d�E��(��D�M�*�s�)�dictr~rGs r0rtzImportFrom._aliases?s$���*�T�5I�5I�5K�*�*�	*r2c��|jddD]}|dvs�njdk(r|jddd�S|dk(rgS|gS)Nr'��.z...�dotted_namer��importrg)r-�ns  r0�get_from_nameszImportFrom.get_from_namesDsZ�����q�r�"�	�A���$��	�
�6�6�]�"��:�:�c��c�?�"�
�(�]��I��3�Jr2c�p�d}|jddD]!}|dvr|t|j�z
}� |S|S)�&The level parameter of ``__import__``.rr'Nr��r*rRrZ)r-r�r�s   r0r�zImportFrom.levelOsL�������q�r�"�	�A��L� ���Q�W�W��%�����	�
�r2c#�K�|jd}|dk(r|jd}n|dk(ry|jdk(r|jddd�}n|g}|D],}|jdk(r|df���|jddd����.y�w)Nr�r�rAr�import_as_namesr�r:rg)r-�last�as_names�as_names    r0r~zImportFrom._as_name_tuplesZs������}�}�R� ���3�;��=�=��$�D�
�S�[���9�9�)�)��}�}�S�q�S�)�H��v�H��	,�G��|�|�v�%��t�m�#��&�&�s��s�+�+�		,�s�BBc��|j�}|jddk(r|gS|j�D��cgc]\}}||gz��
c}}Scc}}w)z�
        The import paths defined in an import statement. Typically an array
        like this: ``[<Name: datetime>, <Name: date>]``.

        :return list of list of Name:
        r�r)r�r*r~)r-�dottedr:rs    r0r�zImportFrom.get_pathsksQ���$�$�&���=�=����#��8�O�37�3G�3G�3I�J�K�D�%��$���J�J��Js�A
Nr�)r3r4r5r)r6r�rtr�r[r�r~r�r r2r0r|r|3s;���D��I�I�*�
	�����,�"Kr2r|c�H�eZdZdZdZdZdd�Zed��Zd�Z	d�Z
d�Zd	�Zy
)�
ImportNamezBFor ``import_name`` nodes. Covers normal imports without ``from``.rr c�b�|j�D��cgc]\}}|xs|d��c}}Scc}}w)z�
        Returns the a list of `Name` that the import defines. The defined names
        is always the first name after `import` or in case an alias - `as` - is
        present that name is returned.
        r��_dotted_as_names)r-rzr�rs    r0r�zImportName.get_defined_names~s1��59�4I�4I�4K�L�[�T�5�� ��a�� �L�L��Ls�+c��y)r�rr rGs r0r�zImportName.level�s��r2c�T�|j�D��cgc]\}}|��	c}}Scc}}wrEr��r-r�rs   r0r�zImportName.get_paths�s#��(,�(=�(=�(?�@���u��@�@��@s�$c#�<K�|jd}|jdk(r|jddd�}n|g}|D]_}|jdk(r|jd}|jd}nd}|jdk(r|g|f���J|jddd�|f���ay�w)z9Generator of (list(path), alias) where alias may be None.r'�dotted_as_namesNr��dotted_as_namerr:rg)r-r�r�r�rs     r0r�zImportName._dotted_as_names�s������-�-��*�����#4�4�&�/�/��!��4�H�'�(�H��
	3�G��|�|�/�/��(�(��+��!�*�*�1�-�����|�|�v�%��i��&�&��&�&�s��s�+�U�2�2�
	3�s�BBc	��t|j�D��cgc]\}}|�t|�dkDrd��c}}�Scc}}w)z�
        This checks for the special case of nested imports, without aliases and
        from statement::

            import foo.bar
        r')�boolr�rRr�s   r0rxzImportName.is_nested�sF���$�*?�*?�*A�8�;�4���}��T��Q���8�9�	9��8s�=
c�B�td�|j�D��S)z=
        :return list of Name: Returns all the alias
        c3�4K�|]\}}|�	||df���y�w)Nr�r )rr�rs   r0rz&ImportName._aliases.<locals>.<genexpr>�s*����*�+�$���(��D��H�%�*�s�)r�r�rGs r0rtzImportName._aliases�s&���*��9N�9N�9P�*�*�	*r2Nr�)
r3r4r5rAr)r6r�r[r�r�r�rxrtr r2r0r�r�ys>��L��D��I�M�����A�3�(9�*r2r�c�<�eZdZdZdZed��Zed��Zdd�Zy)�KeywordStatementz�
    For the following statements: `assert`, `del`, `global`, `nonlocal`,
    `raise`, `return`, `yield`.

    `pass`, `continue` and `break` are not in there, because they are just
    simple keywords and the parser reduces it to a keyword.
    r c� �d|jzS)z�
        Keyword statements start with the keyword and end with `_stmt`. You can
        crosscheck this with the Python grammar.
        z%s_stmt)r�rGs r0r)zKeywordStatement.type�s���4�<�<�'�'r2c�4�|jdjS�Nr)r*rZrGs r0r�zKeywordStatement.keyword�s���}�}�Q��%�%�%r2c��|j}|dk(rt|jd|�S|dvr|jddd�SgS)N�delr')�global�nonlocalr�)r�rar*)r-rzr�s   r0r�z"KeywordStatement.get_defined_names�sL���,�,���e��!�$�-�-��"2�O�D�D��,�,��=�=���A��&�&��	r2Nr�)	r3r4r5rAr6r[r)r�r�r r2r0r�r��s9����I�
�(��(��&��&�r2r�c� �eZdZdZed��Zy)�
AssertStmtr c� �|jdSr r�rGs r0�	assertionzAssertStmt.assertion�r!r2N)r3r4r5r6r[r�r r2r0r�r��s���I�
� �� r2r�c��eZdZdZd�Zy)�
GlobalStmtr c�&�|jddd�S)Nr'r�r�rGs r0�get_global_nameszGlobalStmt.get_global_names�s���}�}�Q�T��T�"�"r2N)r3r4r5r6r�r r2r0r�r��s���I�#r2r�c��eZdZdZy)�
ReturnStmtr Nr_r r2r0r�r��r`r2r�c��eZdZdZdZy)�	YieldExprr&r Nr�r r2r0r�r��rZr2r�c��g}|jdvr(|jddd�D]}|t||�z
}�|S|jdvr|t|jd|�z
}|S|jdvr�|jddk7r�|jd	}|jd
dk(r |j|jd�|S|jd
dk(rl|rj|jddd	�D]U}|jd
k(r!|j|jd�|S|jdk(s�C|j|�|S|S|j|�|S)zk
    A helper function to find the defined names in statements, for loops and
    list comprehensions.
    )�testlist_star_expr�
testlist_comp�exprlist�testlistNr�)�atom�	star_exprr')�power�	atom_exprrA�**r�rr��[�trailerr:)r)r*rar�)�currentrzr�r�r�r.s      r0rara�s���

�E��|�|�V�V��%�%�c��c�*�	<�E��^�E�?�;�;�E�	<�&�L�#
���.�	.�
��� 0� 0�� 3�_�E�E�� �L�
���/�	/����B��4�'��&�&�r�*�G�����"�c�)����W�-�-�a�0�1��L��!�!�!�$��+��#�,�,�R�V��V�4��D��y�y�I�-����T�]�]�1�%5�6���L��y�y�F�*����T�*���L���L�	���W���Lr2c�(�eZdZdZdZdd�Zd�Zd�Zy)�ExprStmtrr c�`�g}|jdjdk(rt|jd|�}tdt	|j�dz
d�D��cgc]@}d|j|dzj
vr t|j||�D]}|���Bc}}|zScc}}w)zG
        Returns a list of `Name` defined before the `=` sign.
        r'�	annassignrr��=)r*r)ra�rangerRrZ)r-rzr�rNr:s     r0r�zExprStmt.get_defined_namess������=�=��� � �K�/�"�4�=�=��#3�_�E�E��1�c�$�-�-�0�1�4�a�8�
���d�m�m�A��E�*�0�0�0�&�t�}�}�Q�'7��I�	
��
�
��
�

��	��
s�AB*c��|jd}|jdk(r8t|j�dk(r|jd}|S|jd}|S)z*Returns the right-hand-side of the equals.r�r�r<r�r'�r*r)rRrhs  r0�get_rhszExprStmt.get_rhssW���}�}�R� ���9�9��#��4�=�=�!�Q�&��}�}�Q�'�����}�}�Q�'���r2c#��K�|jd}|jdk(r(t|j�dkry|jd}|��|jddd�Ed{���y7��w)zZ
        Returns a generator of `+=`, `=`, etc. or None if there is no operation.
        r'r�r�Nr�r��r-rs  r0�yield_operatorszExprStmt.yield_operators$sa�����
�
�a� ���:�:��$��5�>�>�"�a�'���N�N�1�%�E����=�=���A��&�&�&�s�A A*�"A(�#A*Nr�)r3r4r5r)r6r�r�r�r r2r0r�r�s���D��I���'r2r�c��eZdZdZdd�Zy)�	NamedExprrc�4�t|jd|�Sr�r`r|s  r0r�zNamedExpr.get_defined_names6rbr2Nr�)r3r4r5r)r�r r2r0r�r�3s
���D�Ar2r�c���eZdZdZdZd�fd�	Zed��Zed��Zed��Z	d�Z
ed��Zdd	�Zed
��Z
d�Zd�fd�	Zd
�Z�xZS)rz�
    It's a helper class that makes business logic with params much easier. The
    Python grammar defines no ``param`` node. It defines it in a different way
    that is not really suited to working with parameters.
    rc�2��t�|�|�||_yrE)r�r�r,)r-r*r,r�s   �r0r�zParam.__init__Bs���
����"���r2c�T�|jd}|dvrt|j�Sy)zc
        Is `0` in case of `foo`, `1` in case of `*foo` or `2` in case of
        `**foo`.
        r�rr�r�r�s  r0�
star_countzParam.star_countFs,���
�
�a� ���K���u�{�{�#�#�r2c��|jddk(}	|jdt|�z
dk(r|jdt|�z
Sy#t$rYywxYw)z{
        The default is the test node that appears after the `=`. Is `None` in
        case no default is present.
        r�rxrAr�N)r*r\r)r-�	has_commas  r0�defaultz
Param.defaultQse���M�M�"�%��,�	�	��}�}�R�#�i�.�0�1�S�8��}�}�R�#�i�.�%8�9�9�9���	��	�s�8A�	A�Ac��|j�}|jdk(r?|jddk(sJ�t|j�dk(sJ�|jd}|Sy)zz
        The default is the test node that appears after `:`. Is `None` in case
        no annotation is present.
        rr'r&r�r�N)�_tfpdefr)r*rR)r-rr=s   r0r=zParam.annotation^s`��������;�;�(�"��?�?�1�%��,�,�,��v���'�1�,�,�,�����+�J���r2c�T�t|jddv�}|j|S)z1
        tfpdef: see e.g. grammar36.txt.
        rr�)r\r*)r-�offsets  r0r�z
Param._tfpdefms+���T�]�]�1�%��4�5���}�}�V�$�$r2c��|j�jdk(r|j�jdS|j�S)z/
        The `Name` leaf of the param.
        rr)r�r)r*rGs r0r:z
Param.namets;��
�<�<�>���(�*��<�<�>�*�*�1�-�-��<�<�>�!r2c��|jgSrE)r:r|s  r0r�zParam.get_defined_names~s���	�	�{�r2c�Z�|jjj|�}	|jjjd�}||kDr|dz}	|jjjd�}||kDr|dz}|dz
S#t$rY�@wxYw#t$rY|dz
SwxYw)zB
        Property for the positional index of a paramter.
        rr�rr')r,r*r+ro)r-r+�keyword_only_indexs   r0�position_indexzParam.position_index�s���
���$�$�*�*�4�0��	�!%���!5�!5�!;�!;�C�!@���)�)���
��	�!%���!5�!5�!;�!;�C�!@���)�)���
���q�y����	��	���	���q�y��	�s#�/B�/B�	B�B�	B*�)B*c�&�|jdd�S)z=
        Returns the function/lambda of a parameter.
        r$r$)r
rGs r0�get_parent_functionzParam.get_parent_function�s���#�#�I�y�9�9r2c�~��|rt�|�|�S|j}|ddk(r|dd}|j||��S)z�
        Like all the other get_code functions, but includes the param
        `include_comma`.

        :param include_comma bool: If enabled includes the comma in the string output.
        r�rxN)�include_prefix)r��get_coder*�_get_code_for_children)r-r��
include_commar*r�s    �r0r�zParam.get_code�sV�����7�#�N�3�3��=�=���B�<�3�����}�H��*�*��)�+�
�	
r2c���|j�dnd|jj�z}dt|�j�dt	|j��|z�d�S)Nr�z=%srkrsrl)r�r�r)r3r�r�)r-r�s  r0rnzParam.__repr__�sI�����,�"�%�$�,�,�:O�:O�:Q�2Q��!�$�Z�0�0�#�d�l�l�n�2E��2O�P�Pr2rEr�)TT)r3r4r5rAr)r�r[r�r�r=r�r:r�r�r�r�rnr�r�s@r0rr:s�����
�D�������
��
�����%��"��"������*:�
�$Qr2rc��eZdZdZdZdd�Zy)�SyncCompForrr c�4�t|jd|�S)zN
        Returns the a list of `Name` that the comprehension defines.
        r'r`r|s  r0r�zSyncCompFor.get_defined_names�s��
�d�m�m�A�.��@�@r2Nr�)r3r4r5r)r6r�r r2r0r�r��s���D��I�Ar2r�c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	r�zO
    This class exists for the sole purpose of creating an immutable dict.
    c��||_yrE��_dict)r-r�s  r0r�zUsedNamesMapping.__init__�s	����
r2c� �|j|SrEr�)r-�keys  r0�__getitem__zUsedNamesMapping.__getitem__�s���z�z�#��r2c�,�t|j�SrE)rRr�rGs r0�__len__zUsedNamesMapping.__len__�s���4�:�:��r2c�,�t|j�SrE)�iterr�rGs r0�__iter__zUsedNamesMapping.__iter__�r�r2c��t|�SrE)�idrGs r0r�zUsedNamesMapping.__hash__�s���$�x�r2c�
�||uSrEr r�s  r0r�zUsedNamesMapping.__eq__�s���u�}�r2N)
r3r4r5rAr�r�r�r�r�r�r r2r0r�r��s%������ ��r2r�)JrAr��collections.abcr�ImportError�collections�typingr�
parso.treerrrrr	r
�parso.python.prefixr�parso.utilsr�set�_FLOW_CONTAINERSr.r�r�r�rr8rCrVr^rbrdrfrhrprur�r�r�r�r�r�r�r�r�r�r�r�r�r�r
rr?rHrJrYr\rdrkrrr|r�r�r�r�r�r�rar�r�rr��CompForr�r r2r0�<module>r	s��*�X
�$�'��R�R�,�#��<�=���w�
�6�7�:J�J���:����������
�}�-�.����8��,%��d�%�08�:�8��[�(����d���k�9���i���
�$�
�D�j�D�1��1�h�j���W��
5�W�5�"�J���:����� � ��#�%;��
�"�$:��
4G�N�N�4G�n3 �U�3 �l���
�%��6(�K�(�0*�Zi�{�i�X*E�X�*E�Z�>��*�T�*�Z���
A�d�A�
�d�
�  �t� �.(�^�(�6CK��CK�L8*��8*�v�~��> �!� �#�!�#��!�����
�:('�~�~�('�VA��A�wQ�N�wQ�t	A�.�	A����w���k$�$�#�#�$�s�I1�1J�?J

Youez - 2016 - github.com/yon3zu
LinuXploit