§
    ŒŸjkE  ã                   óT  — d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZmZm	Z	m
Z
mZmZmZmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZ erddlmZmZ  G d„ d	e j        ¬
¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z dZ!ej"        dd…         dk    r
e!dz  Z!e!dz  Z!dd„Z#dS )é    N)ÚModule)ÚIterableÚIteratorÚListÚOptionalÚTupleÚAnyÚcastÚTYPE_CHECKINGé   )ÚLineNumbers)	ÚTokenÚmatch_tokenÚis_non_coding_tokenÚpatched_generate_tokensÚ	last_stmtÚannotate_fstring_nodesÚgenerate_tokensÚ	is_moduleÚis_stmt)ÚAstNodeÚ	TokenInfoc                   óR   — e Zd Zdededdfd„Zej        d„ ¦   «         Zd
d„Zd
d	„Z	dS )ÚASTTextBaseÚsource_textÚfilenameÚreturnNc                 óh   — || _         t          |¦  «        }|| _        t          |¦  «        | _        d S ©N)Ú	_filenameÚstrÚ_textr   Ú_line_numbers)Úselfr   r   s      ú`/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/asttokens/asttokens.pyÚ__init__zASTTextBase.__init__"   s5   € Ø€D„Nõ
 �kÑ"Ô"€Kà€D„JÝ$ [Ñ1Ô1€DÔÐÐó    c                 ó   — t           ‚)áÎ  
    Returns two ``(lineno, col_offset)`` tuples for the start and end of the given node.
    If the positions can't be determined, or the nodes don't correspond to any particular text,
    returns ``(1, 0)`` for both.

    ``padded`` corresponds to the ``padded`` argument to ``ast.get_source_segment()``.
    This means that if ``padded`` is True, the start position will be adjusted to include
    leading whitespace if ``node`` is a multiline statement.
    )ÚNotImplementedError©r$   ÚnodeÚpaddeds      r%   Úget_text_positionszASTTextBase.get_text_positions-   s
   € õ Ðr'   Tc                 óp   — |                       ||¦  «        \  }} | j        j        |Ž  | j        j        |Ž fS )a  
    Returns the (startpos, endpos) positions in source text corresponding to the given node.
    Returns (0, 0) for nodes (like `Load`) that don't correspond to any particular text.

    See ``get_text_positions()`` for details on the ``padded`` argument.
    )r.   r#   Úline_to_offset©r$   r,   r-   ÚstartÚends        r%   Úget_text_rangezASTTextBase.get_text_range;   sG   € ð ×(Ò(¨¨vÑ6Ô6�J€Eˆ3à'€dÔÔ'¨Ð/Ø'€dÔÔ'¨Ð-ðð r'   c                 óR   — |                       ||¦  «        \  }}| j        ||…         S )zÚ
    Returns the text corresponding to the given node.
    Returns '' for nodes (like `Load`) that don't correspond to any particular text.

    See ``get_text_positions()`` for details on the ``padded`` argument.
    )r4   r"   r1   s        r%   Úget_textzASTTextBase.get_textI   s.   € ð ×$Ò$ T¨6Ñ2Ô2�J€Eˆ3ØŒ:�e˜S�jÔ!Ð!r'   )T)
Ú__name__Ú
__module__Ú__qualname__r!   r&   ÚabcÚabstractmethodr.   r4   r6   © r'   r%   r   r   !   s„   € € € € € ð	2 #ð 	2°ð 	2¸ð 	2ð 	2ð 	2ð 	2ð Ôðð ñ Ôððð ð ð ð	"ð 	"ð 	"ð 	"ð 	"ð 	"r'   r   )Ú	metaclassc                   óÊ   ‡ — e Zd ZdZdˆ fd„	Zd„ Zd„ Zed„ ¦   «         Zed	„ ¦   «         Z	ed
„ ¦   «         Z
ed„ ¦   «         Zd„ Zd„ Zd„ Zdd„Zdd„Zdd„Z	 dd„Zdd„Zd„ Zˆ xZS )Ú	ASTTokensaš  
  ASTTokens maintains the text of Python code in several forms: as a string, as line numbers, and
  as tokens, and is used to mark and access token and position information.

  ``source_text`` must be a unicode or UTF8-encoded string. If you pass in UTF8 bytes, remember
  that all offsets you'll get are to the unicode text, which is available as the ``.text``
  property.

  If ``parse`` is set, the ``source_text`` will be parsed with ``ast.parse()``, and the resulting
  tree marked with token info and made available as the ``.tree`` property.

  If ``tree`` is given, it will be marked and made available as the ``.tree`` property. In
  addition to the trees produced by the ``ast`` module, ASTTokens will also mark trees produced
  using ``astroid`` library <https://www.astroid.org>.

  If only ``source_text`` is given, you may use ``.mark_tokens(tree)`` to mark the nodes of an AST
  tree created separately.
  FNú	<unknown>c                 ó‚  •— t          t          | ¦  «                             ||¦  «         |rt          j        ||¦  «        n|| _        |€t          | j        ¦  «        }t          |  	                    |¦  «        ¦  «        | _
        d„ | j
        D ¦   «         | _        | j        r|                      | j        ¦  «         d S d S )Nc                 ó   — g | ]	}|j         ‘Œ
S r<   )Ústartpos)Ú.0Útoks     r%   ú
<listcomp>z&ASTTokens.__init__.<locals>.<listcomp>u   s   € Ð@Ð@Ð@¨C˜3œ<Ð@Ð@Ð@r'   )Úsuperr?   r&   ÚastÚparseÚ_treer   r"   ÚlistÚ_translate_tokensÚ_tokensÚ_token_offsetsÚmark_tokens)r$   r   rI   Útreer   ÚtokensÚ	__class__s         €r%   r&   zASTTokens.__init__i   s¾   ø€ å	�)�TÑÔ×#Ò# K°Ñ:Ô:Ð:à5:ÐD•”˜;¨Ñ1Ô1Ð1À€D„Jð €~Ý˜tœzÑ*Ô*€fÝ˜×.Ò.¨vÑ6Ô6Ñ7Ô7€D„Lð AÐ@°4´<Ð@Ñ@Ô@€DÔà„zð #Ø
×Ò�t”zÑ"Ô"Ð"Ð"Ð"ð#ð #r'   c                 óN   — ddl m}  || ¦  «                             |¦  «         dS )aq  
    Given the root of the AST or Astroid tree produced from source_text, visits all nodes marking
    them with token and position information by adding ``.first_token`` and
    ``.last_token`` attributes. This is done automatically in the constructor when ``parse`` or
    ``tree`` arguments are set, but may be used manually with a separate AST or Astroid tree.
    r   )Ú
MarkTokensN)rO   rT   Ú
visit_tree)r$   Ú	root_noderT   s      r%   rO   zASTTokens.mark_tokensz   s:   € ð (Ð'Ð'Ð'Ð'Ð'Ø€JˆtÑÔ×Ò 	Ñ*Ô*Ð*Ð*Ð*r'   c              #   ó"  K  — t          t          |¦  «        ¦  «        D ]o\  }}|\  }}}}}t          ||||||| j                             |d         |d         ¦  «        | j                             |d         |d         ¦  «        ¦  «        V — ŒpdS )zS
    Translates the given standard library tokens into our own representation.
    r   r   N)Ú	enumerater   r   r#   r0   )	r$   Úoriginal_tokensÚindexrE   Útok_typeÚtok_strr2   r3   Úlines	            r%   rL   zASTTokens._translate_tokens†   s¹   è è € õ
  Õ 7¸Ñ HÔ HÑIÔIð Eð E‰
ˆˆsØ,/Ñ)€h�˜  TÝ�(˜G U¨C°°uØÔ$×3Ò3°E¸!´H¸eÀA¼hÑGÔGØÔ$×3Ò3°C¸´F¸CÀ¼FÑCÔCñEô Eð Eð Eð Eð EðEð Er'   c                 ó   — | j         S )z,The source code passed into the constructor.)r"   ©r$   s    r%   ÚtextzASTTokens.text‘   ó   € ð Œ:Ðr'   c                 ó   — | j         S )zIThe list of tokens corresponding to the source code from the constructor.)rM   r_   s    r%   rQ   zASTTokens.tokens—   s   € ð Œ<Ðr'   c                 ó   — | j         S )zTThe root of the AST tree passed into the constructor or parsed from the source code.)rJ   r_   s    r%   rP   zASTTokens.tree�   ra   r'   c                 ó   — | j         S )zThe filename that was parsed)r    r_   s    r%   r   zASTTokens.filename£   s   € ð Œ>Ðr'   c                 óR   — | j         t          j        | j        |¦  «        dz
           S )z£
    Returns the token containing the given character offset (0-based position in source text),
    or the preceeding token if the position is between tokens.
    r   )rM   ÚbisectrN   )r$   Úoffsets     r%   Úget_token_from_offsetzASTTokens.get_token_from_offset©   s%   € ð Œ<�œ dÔ&9¸6ÑBÔBÀQÑFÔGÐGr'   c                 ó^   — |                       | j                             ||¦  «        ¦  «        S )zŽ
    Returns the token containing the given (lineno, col_offset) position, or the preceeding token
    if the position is between tokens.
    )rh   r#   r0   ©r$   ÚlinenoÚ
col_offsets      r%   Ú	get_tokenzASTTokens.get_token±   s,   € ð ×%Ò% dÔ&8×&GÒ&GÈÐPZÑ&[Ô&[Ñ\Ô\Ð\r'   c                 ó`   — |                       || j                             ||¦  «        ¦  «        S )zd
    Same as get_token(), but interprets col_offset as a UTF8 offset, which is what `ast` uses.
    )rm   r#   Úfrom_utf8_colrj   s      r%   Úget_token_from_utf8zASTTokens.get_token_from_utf8¼   s+   € ð
 �>Š>˜& $Ô"4×"BÒ"BÀ6È:Ñ"VÔ"VÑWÔWÐWr'   c                 óº   — |j         dz   }|sCt          | j        |         j        ¦  «        r$|dz  }t          | j        |         j        ¦  «        °$| j        |         S )z 
    Returns the next token after the given one. If include_extra is True, includes non-coding
    tokens from the tokenize module, such as NL and COMMENT.
    r   ©rZ   r   rM   Útype©r$   rE   Úinclude_extraÚis       r%   Ú
next_tokenzASTTokens.next_tokenÃ   ó`   € ð 	Œ	�A‰€AØð Ý ¤¨Q¤Ô 4Ñ5Ô5ð Ø	ˆQ‰ˆõ   ¤¨Q¤Ô 4Ñ5Ô5ð àŒ<˜Œ?Ðr'   c                 óº   — |j         dz
  }|sCt          | j        |         j        ¦  «        r$|dz  }t          | j        |         j        ¦  «        °$| j        |         S )z¥
    Returns the previous token before the given one. If include_extra is True, includes non-coding
    tokens from the tokenize module, such as NL and COMMENT.
    r   rr   rt   s       r%   Ú
prev_tokenzASTTokens.prev_tokenÏ   rx   r'   c                 óì   — |}|r| j         n| j        }t          |||¦  «        sPt          j        |j        ¦  «        s7 ||d¬¦  «        }t          |||¦  «        st          j        |j        ¦  «        ¯7|S )z÷
    Looks for the first token, starting at start_token, that matches tok_type and, if given, the
    token string. Searches backwards if reverse is True. Returns ENDMARKER token if not found (you
    can check it with `token.ISEOF(t.type)`).
    T©ru   )rz   rw   r   ÚtokenÚISEOFrs   )r$   Ústart_tokenr[   r\   ÚreverseÚtÚadvances          r%   Ú
find_tokenzASTTokens.find_tokenÛ   s„   € ð 	€AØ!(Ð=ˆdŒoˆo¨d¬o€GÝ˜!˜X wÑ/Ô/ð )½¼ÀAÄFÑ8KÔ8Kð )Ø
ˆ'�! 4Ð
(Ñ
(Ô
(€aõ ˜!˜X wÑ/Ô/ð )½¼ÀAÄFÑ8KÔ8Kð )à€Hr'   c              #   óª   K  — t          |j        |j        dz   ¦  «        D ]2}|st          | j        |         j        ¦  «        s| j        |         V — Œ3dS )z²
    Yields all tokens in order from first_token through and including last_token. If
    include_extra is True, includes non-coding tokens such as tokenize.NL and .COMMENT.
    r   N)ÚrangerZ   r   rM   rs   )r$   Úfirst_tokenÚ
last_tokenru   rv   s        r%   Útoken_rangezASTTokens.token_rangeè   sj   è è € õ �;Ô$ jÔ&6¸Ñ&:Ñ;Ô;ð ð ˆØ	ð Õ1°$´,¸q´/Ô2FÑGÔGð ØŒl˜1ŒoÐÐÐøðð r'   c                 óF   — |                       |j        |j        |¬¦  «        S )z�
    Yields all tokens making up the given node. If include_extra is True, includes non-coding
    tokens such as tokenize.NL and .COMMENT.
    r|   )rˆ   r†   r‡   )r$   r,   ru   s      r%   Ú
get_tokenszASTTokens.get_tokensö   s$   € ð ×Ò˜DÔ,¨d¬oÈ]ÐÑ[Ô[Ð[r'   c                 óÎ   — t          |d¦  «        sdS |j        j        }|j        j        }|r6t          d„ |                      |¦  «        D ¦   «         ¦  «        r
|d         df}||fS )r)   r†   ©©r   r   r�   c              3   óJ   K  — | ]}t          |t          j        ¦  «        V — Œd S r   )r   r}   ÚNEWLINE)rD   r�   s     r%   ú	<genexpr>z/ASTTokens.get_text_positions.<locals>.<genexpr>  s.   è è € ÐSÐS¸•k !¥U¤]Ñ3Ô3ÐSÐSÐSÐSÐSÐSr'   r   )Úhasattrr†   r2   r‡   r3   ÚanyrŠ   r1   s        r%   r.   zASTTokens.get_text_positionsþ   sy   € õ �4˜Ñ'Ô'ð Øˆ^àÔÔ"€EØ
Œ/Ô
€CØð •#ÐSÐS¸T¿_º_ÈTÑ=RÔ=RÐSÑSÔSÑSÔSð à�QŒx˜ˆm€eà�#ˆ:Ðr'   )FNr@   N)F)NF)r7   r8   r9   Ú__doc__r&   rO   rL   Úpropertyr`   rQ   rP   r   rh   rm   rp   rw   rz   rƒ   rˆ   rŠ   r.   Ú__classcell__©rR   s   @r%   r?   r?   U   s†  ø€ € € € € ðð ð&#ð #ð #ð #ð #ð #ð"
+ð 
+ð 
+ð	Eð 	Eð 	Eð ðð ñ „8ðð
 ðð ñ „8ðð
 ðð ñ „8ðð
 ðð ñ „8ðð
Hð Hð Hð	]ð 	]ð 	]ðXð Xð Xð
ð 
ð 
ð 
ð
ð 
ð 
ð 
ðð ð ð ð  !&ðð ð ð ð\ð \ð \ð \ðð ð ð ð ð ð r'   r?   c                   ó\   ‡ — e Zd ZdZd	ˆ fd„	Zed„ ¦   «         Zed„ ¦   «         Zd„ Zd„ Z	ˆ xZ
S )
ÚASTTextaF  
  Supports the same ``get_text*`` methods as ``ASTTokens``,
  but uses the AST to determine the text positions instead of tokens.
  This is faster than ``ASTTokens`` as it requires less setup work.

  It also (sometimes) supports nodes inside f-strings, which ``ASTTokens`` doesn't.

  Some node types and/or Python versions are not supported.
  In these cases the ``get_text*`` methods will fall back to using ``ASTTokens``
  which incurs the usual setup cost the first time.
  If you want to avoid this, check ``supports_tokenless(node)`` before calling ``get_text*`` methods.
  Nr@   c                 ó¬   •— t          t          | ¦  «                             ||¦  «         || _        | j        �t	          | j        ¦  «         d | _        d S r   )rG   r˜   r&   rJ   r   Ú
_asttokens)r$   r   rP   r   rR   s       €r%   r&   zASTText.__init__"  sM   ø€ å	�'�4ÑÔ×!Ò! +¨xÑ8Ô8Ð8à€D„JØ„zÐÝ˜TœZÑ(Ô(Ð(à€D„O€O€Or'   c                 óŽ   — | j         €8t          j        | j        | j        ¦  «        | _         t          | j         ¦  «         | j         S r   )rJ   rH   rI   r"   r    r   r_   s    r%   rP   zASTText.tree,  s;   € ð „zÐÝ”9˜TœZ¨¬Ñ8Ô8€d„jÝ˜TœZÑ(Ô(Ð(ØŒ:Ðr'   c                 ój   — | j         €&t          | j        | j        | j        ¬¦  «        | _         | j         S )N)rP   r   )rš   r?   r"   rP   r    r_   s    r%   Ú	asttokenszASTText.asttokens4  s;   € ð „ÐÝ!Ø
Œ*ØŒyØ”>ðñ ô €d„oð
 Œ?Ðr'   c                 óÆ  — t          |¦  «        r.d| j                             t          | j        ¦  «        ¦  «        fS t          |dd¦  «        €dS |sJ ‚t          |dg ¦  «        }|s"t          |dd¦  «        }t          |dg ¦  «        }|r	|d         }n|}|j        }t          |¦  «        }|r9||j        k    s+||j        k    r#t          |d	d¦  «        rt          |¦  «        rd}n | j         
                    ||j        ¦  «        }||f}	t          t          |j        ¦  «        }
t          t          |j        ¦  «        }| j         
                    |
|¦  «        }|
|f}|	|fS )
zF
    Version of ``get_text_positions()`` that doesn't use tokens.
    r�   rk   NrŒ   Údecorator_listÚ
decoratorsÚnodesr   Údoc_node)r   r#   Úoffset_to_lineÚlenr"   Úgetattrrk   r   Ú
end_linenor   ro   rl   r
   ÚintÚend_col_offset)r$   r,   r-   r    Údecorators_nodeÚ
start_nodeÚstart_linenoÚend_nodeÚstart_col_offsetr2   r¦   r¨   r3   s                r%   Ú_get_text_positions_tokenlessz%ASTText._get_text_positions_tokenless?  s�  € õ
 ��„ð Hð
 �TÔ'×6Ò6µs¸4¼:±´ÑGÔGÐGÐGåˆt�X˜tÑ$Ô$Ð,Øˆ^à€K€K€Kå˜Ð/°Ñ4Ô4€JØð 9å  l°DÑ9Ô9€oÝ˜?¨G°RÑ8Ô8€jØð ð ˜a”=€j€jà€jàÔ$€LÝ˜‰Œ€Hð ð _Ø˜œÒ'Ð'ð ˜DœOÒ+Ð+Ý˜˜j¨$Ñ/Ô/ð ,å˜‘”ð ,ð
 ÐÐàÔ+×9Ò9¸,È
ÔH]Ñ^Ô^ÐàÐ+Ð,€Eõ
 •c˜8Ô.Ñ/Ô/€JÝ�#˜xÔ6Ñ7Ô7€NØÔ'×5Ò5°jÀ.ÑQÔQ€NØ�~Ð
&€Cà�#ˆ:Ðr'   c                 ó¨   — t          |dd¦  «        rdS t          |¦  «        r|                      ||¦  «        S | j                             ||¦  «        S )r)   Ú_broken_positionsNrŒ   )r¥   Úsupports_tokenlessr®   r�   r.   r+   s      r%   r.   zASTText.get_text_positions�  s\   € õ ˆtÐ(¨$Ñ/Ô/ð àˆ^å˜$ÑÔð >Ø×/Ò/°°fÑ=Ô=Ð=àŒ>×,Ò,¨T°6Ñ:Ô:Ð:r'   )Nr@   )r7   r8   r9   r“   r&   r”   rP   r�   r®   r.   r•   r–   s   @r%   r˜   r˜     sŸ   ø€ € € € € ðð ðð ð ð ð ð ð ðð ñ „8ðð ðð ñ „8ðð@ð @ð @ðD;ð ;ð ;ð ;ð ;ð ;ð ;r'   r˜   )Ú	argumentsÚ	ArgumentsÚwithitemé   )é   é   )ÚargÚStarred)ÚSliceÚExtSliceÚIndexÚkeywordc                 ó  — t          | ¦  «        j        t          vort          | t          j        ¦  «         o6| duo2t          | ¦  «        j        dk    ot          | j        ¦  «        j        dv  odt          j         	                    ¦   «         vS )av  
  Returns True if the Python version and the node (if given) are supported by
  the ``get_text*`` methods of ``ASTText`` without falling back to ``ASTTokens``.
  See ``ASTText`` for why this matters.

  The following cases are not supported:

    - PyPy
    - ``ast.arguments`` / ``astroid.Arguments``
    - ``ast.withitem``
    - ``astroid.Comprehension``
    - ``astroid.AssignName`` inside ``astroid.Arguments`` or ``astroid.ExceptHandler``
    - The following nodes in Python 3.8 only:
      - ``ast.arg``
      - ``ast.Starred``
      - ``ast.Slice``
      - ``ast.ExtSlice``
      - ``ast.Index``
      - ``ast.keyword``
  NÚ
AssignName)r³   ÚExceptHandlerÚpypy)
rs   r7   Ú_unsupported_tokenless_typesÚ
isinstancerH   ÚASTÚparentÚsysÚversionÚlower)r,   s    r%   r±   r±      s”   € õ. ˆ4�j„jÔÕ!=Ð=ð 
,õ �t�SœWÑ%Ô%Ð%ð 	
¨$°dÐ*:ð 	
å�‰JŒJÔ <Ò/ð MÝ�T”[Ñ!Ô!Ô*Ð.LÐLðð
,ð �œ×)Ò)Ñ+Ô+Ð
+ðr'   r   )$r:   rH   rf   rÆ   r}   r   Útypingr   r   r   r   r   r	   r
   r   Úline_numbersr   Úutilr   r   r   r   r   r   r   r   r   r   r   ÚABCMetar   r?   r˜   rÂ   Úversion_infor±   r<   r'   r%   ú<module>rÎ      s  ðð €
€
€
Ø 
€
€
€
Ø €€€Ø 
€
€
€
Ø €€€Ø Ð Ð Ð Ð Ð Ø VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ VÐ Và %Ð %Ð %Ð %Ð %Ð %ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð
 ð 'Ø&Ð&Ð&Ð&Ð&Ð&Ð&Ð&ð1"ð 1"ð 1"ð 1"ð 1"˜CœKð 1"ñ 1"ô 1"ð 1"ðh}ð }ð }ð }ð }�ñ }ô }ð }ð@~;ð ~;ð ~;ð ~;ð ~;ˆkñ ~;ô ~;ð ~;ðF  FÐ ØÔ�B�Q�BÔ˜6Ò!Ð!àÐ"4Ñ4ÐàÐ"KÑKÐð"ð "ð "ð "ð "ð "r'   