| 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 : |
�
̑�aC� � � � d Z ddlZ ddlmZ ddlmZ ddlm Z m
Z
mZmZm
Z
mZ ddlmZ ddlmZ eg d�� Z ed d
g� ez Z eg d�� ez Z eg d�� Z ed
dg� Z G d� d� Z G d� d� Z G d� dee� Z G d� de� Z G d� dee
� Z G d� dee � Z G d� dee� Z G d� de
e� Z G d� d e� Z! G d!� d"e� Z" G d#� d$e� Z# G d%� d&e� Z$ G d'� d(e$� Z% G d)� d*e$� Z& G d+� d,e� Z' G d-� d.e� Z( G d/� d0e� Z) G d1� d2� Z* G d3� d4ee*� Z+ G d5� d6ee*� Z, G d7� d8ee� Z- G d9� d:e-� Z. G d;� d<e� Z/ G d=� d>e-� Z0 G d?� d@e0� Z1dA� Z2 G dB� dCe0� Z3 G dD� dEe3� Z4 G dF� dGe� Z5 G dH� dIe5� Z6 G dJ� dKe5� Z7 G dL� dMe5� Z8 G dN� dOe5� Z9 G dP� dQe5� Z: G dR� dSe� Z; G dT� dUe;� Z< G dV� dWe;� Z= G dX� dYe� Z> G dZ� d[e>� Z? G d\� d]e>� Z@ G d^� d_e>� ZA G d`� dae� ZBdb� ZC G dc� ddee� ZD G de� dfe� ZE G dg� dhe� ZF G di� dje� ZGeGZH G dk� dle� ZIy# e$ r
ddlmZ Y ��qw xY w)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)r r � decorated�
async_funcdef) � expr_stmt�
sync_comp_forr r �import_name�import_from�param�del_stmt�namedexpr_testr r c � � e Zd ZdZd� Zy)�DocstringMixin� c �� � | j dk( r| j d }n�| j dv rJ| j | j j d� dz }|j dk( rN|j d }n>| j }|j j }|j |� }|sy||dz
}|j dk( r|j d }|j d k( r|S y)
zN
Returns the string leaf of a docstring. e.g. ``r'''foo'''``.
�
file_inputr ��funcdef�classdef�:� r Nr �string)�type�children�index�parent)�self�noder �cr+ s �3/usr/lib/python3/dist-packages/parso/python/tree.py�get_doc_nodezDocstringMixin.get_doc_nodeJ s� � � �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__r1 r r2 r0 r r G s � ��I�r2 r c � � e Zd ZdZdZd� Zy)�PythonMixinz)
Some Python specific utilities.
r c �� � | j D ]_ }t |t � r6|j dk( s�#|j |cxk r|j
k s�C|c S �I|j
|� }|��]|c S y)z�
Given a (line, column) tuple, returns a :py:class:`Name` or ``None`` if
there is no name at that position.
�nameN)r* �
isinstancer r) � start_pos�end_pos�get_name_of_position)r- �positionr/ �results r0 r>