| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/parso/python/__pycache__/ |
Upload File : |
�
̑�aC� � �: � d Z ddlZ ddlmZ n# e$ r ddlmZ Y nw xY wddlmZ 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� � ZIdS )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� ZdS )�DocstringMixin� c � � | j dk r| j d }n�| j dv rA| j | j � d� � dz }|j dk r
|j d }n7| j }|j j }|� |� � }|sdS ||dz
}|j dk r
|j d }|j d k r|S dS )
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��$�$��=��#�D�D�
�Y�1�
1�
1��=���!4�!4�S�!9�!9�A�!=�>�D��y�G�#�#��}�Q�'����+�K��"�+�A��G�G�K�(�(�E��
��t��U�Q�Y�<�D��9�
�%�%��=��#�D��9�� � ��K��t� N)�__name__�
__module__�__qualname__� __slots__r1 r r2 r0 r r G s( � � � � � ��I�� � � � r2 r c � � e Zd ZdZdZd� ZdS )�PythonMixinz)
Some Python specific utilities.
r c �� � | j D ]\}t |t � � r*|j dk r|j |cxk r|j k rn �<|c S �A|� |� � }|�|c S �]dS )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>