§
    �Ÿj2  ã                   óØ   — d Z ddlZddlmZ ddlZ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  ej        ej        d„ ej        D ¦   «         ¦  «        Zd
d„Z G d„ dej        ¦  «        Zd	„ ZdS )zéCompiler tools with improved interactive support.

Provides compilation machinery similar to codeop, but with caching support so
we can provide interactive tracebacks.

Authors
-------
* Robert Kern
* Fernando Perez
* Thomas Kluyver
é    N)ÚPyCF_ONLY_AST)Úcontextmanagerc              #   óJ   K  — | ]}t          t          |¦  «        j        V — Œd S ©N)ÚgetattrÚ
__future__Úcompiler_flag)Ú.0Úfnames     úd/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/IPython/core/compilerop.pyú	<genexpr>r   /   sK   è è € ð Ið IØ"'õ &¥j°%Ñ8Ô8ÔFð Ið Ið Ið Ið Ið Ió    c                 ó°   — t          j        |                      d¦  «        ¦  «                             ¦   «         }d                     ||dd…         ¦  «        S )zf Compute a (probably) unique name for code for caching.

    This now expects code to be unicode.
    zutf-8z<ipython-input-{0}-{1}>Né   )ÚhashlibÚsha1ÚencodeÚ	hexdigestÚformat)ÚcodeÚnumberÚhash_digests      r   Ú	code_namer   6   sL   € õ
 ”,˜tŸ{š{¨7Ñ3Ô3Ñ4Ô4×>Ò>Ñ@Ô@€Kð %×+Ò+¨F°KÀÀÀÔ4DÑEÔEÐEr   c                   óf   — e Zd ZdZd„ Zdd„Zd„ Zed„ ¦   «         Zd„ Z	d	„ Z
dd„Zed„ ¦   «         ZdS )ÚCachingCompilerzFA compiler that caches code compiled from interactive statements.
    c                 óR   — t           j                             | ¦  «         i | _        d S r   )ÚcodeopÚCompileÚ__init__Ú_filename_map©Úselfs    r   r   zCachingCompiler.__init__I   s(   € ÝŒ×Ò Ñ%Ô%Ð%ð
  ˆÔÐÐr   ú	<unknown>Úexecc                 óB   — t          |||| j        t          z  d¦  «        S )zÅParse code to an AST with the current compiler flags active.

        Arguments are exactly the same as ast.parse (in the standard library),
        and are passed to the built-in compile function.é   )ÚcompileÚflagsr   )r"   ÚsourceÚfilenameÚsymbols       r   Ú	ast_parsezCachingCompiler.ast_parseQ   s!   € õ
 �v˜x¨°´½mÑ1KÈQÑOÔOÐOr   c                 ó(   — t           j        | _        dS )z&Reset compiler flags to default state.N)r   ÚPyCF_DONT_IMPLY_DEDENTr(   r!   s    r   Úreset_compiler_flagsz$CachingCompiler.reset_compiler_flagsX   s   € õ Ô2ˆŒ
ˆ
ˆ
r   c                 ó   — | j         S )z;Flags currently active in the compilation process.
        ©r(   r!   s    r   Úcompiler_flagszCachingCompiler.compiler_flags^   s   € ð ŒzÐr   c                 ó"   — t          ||¦  «        S )a¹  Compute filename given the code, and the cell number.

        Parameters
        ----------
        raw_code : str
            The raw cell code.
        transformed_code : str
            The executable Python source code to cache and compile.
        number : int
            A number which forms part of the code's name. Used for the execution
            counter.

        Returns
        -------
        The computed filename.
        )r   )r"   Úraw_codeÚtransformed_coder   s       r   Úget_code_namezCachingCompiler.get_code_named   s   € õ" Ð)¨6Ñ2Ô2Ð2r   c                 ó<   — || j         v rdd| j         |         z  fS dS )aN  Return a user-friendly label and name for a code block.

        Parameters
        ----------
        name : str
            The name for the code block returned from get_code_name

        Returns
        -------
        A (label, name) pair that can be used in tracebacks, or None if the default formatting should be used.
        ÚCellzIn[%s]N)r    )r"   Únames     r   Úformat_code_namez CachingCompiler.format_code_namew   s2   € ð �4Ô%Ð%Ð%Ø˜8 dÔ&8¸Ô&>Ñ>Ð>Ð>ð &Ð%r   r   Nc                 óÌ   — |€|}|                       |||¦  «        }|| j        |<   t          |¦  «        dd„ |                     ¦   «         D ¦   «         |f}|t          j        |<   |S )ah  Make a name for a block of code, and cache the code.

        Parameters
        ----------
        transformed_code : str
            The executable Python source code to cache and compile.
        number : int
            A number which forms part of the code's name. Used for the execution
            counter.
        raw_code : str
            The raw code before transformation, if None, set to `transformed_code`.

        Returns
        -------
        The name of the cached code (as a string). Pass this as the filename
        argument to compilation, so that tracebacks are correctly hooked up.
        Nc                 ó   — g | ]}|d z   ‘ŒS )ú
© )r
   Úlines     r   ú
<listcomp>z)CachingCompiler.cache.<locals>.<listcomp>®   s   € ÐCÐCÐC˜TˆT�D‰[ÐCÐCÐCr   )r6   r    ÚlenÚ
splitlinesÚ	linecacheÚcache)r"   r5   r   r4   r9   Úentrys         r   rD   zCachingCompiler.cache†   s‚   € ð$ ÐØ'ˆHà×!Ò! (Ð,<¸fÑEÔEˆð $*ˆÔ˜4Ñ õ Ð Ñ!Ô!ØØCÐCÐ%5×%@Ò%@Ñ%BÔ%BÐCÑCÔCØð	
ˆð !&�	Œ˜ÑØˆr   c              #   ó–   K  — | j          |z  }| j         |z  | _         	 d V — | xj         | z  c_         d S # | xj         | z  c_         w xY wr   r1   )r"   r(   Úturn_on_bitss      r   Úextra_flagszCachingCompiler.extra_flags´   sf   è è € ð œ
�{ UÑ*ˆð ”Z %Ñ'ˆŒ
ð	(ØˆEˆEˆEð ˆJŒJ˜<˜-Ñ'ˆJŒJˆJˆJøˆDˆJŒJ˜<˜-Ñ'ˆJŒJˆJˆJˆJˆJs	   ž5 µA)r#   r$   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r,   r/   Úpropertyr2   r6   r:   rD   r   rH   r>   r   r   r   r   E   s½   € € € € € ðð ð ð  ð  ðPð Pð Pð Pð3ð 3ð 3ð ðð ñ „Xðð
3ð 3ð 3ð&?ð ?ð ?ð,ð ,ð ,ð ,ð\ ð(ð (ñ „^ð(ð (ð (r   r   c                  ón   — ddl }|                     dt          d¬¦  «         t          j        ¦   «          dS )aä  Deprecated since IPython 8.6.  Call linecache.checkcache() directly.

    It was already not necessary to call this function directly.  If no
    CachingCompiler had been created, this function would fail badly.  If
    an instance had been created, this function would've been monkeypatched
    into place.

    As of IPython 8.6, the monkeypatching has gone away entirely.  But there
    were still internal callers of this function, so maybe external callers
    also existed?
    r   NzHDeprecated Since IPython 8.6, Just call linecache.checkcache() directly.é   )Ú
stacklevel)ÚwarningsÚwarnÚDeprecationWarningrC   Ú
checkcache)ÚargsrQ   s     r   Úcheck_linecache_ipythonrV   Ã   sH   € ð €O€O€Oà‡M‚MØRÝØð ñ ô ð õ
 ÔÑÔÐÐÐr   )r   )rL   r   Úastr   r   Ú	functoolsr   rC   ÚoperatorÚtimeÚ
contextlibr   ÚreduceÚor_Úall_feature_namesÚ	PyCF_MASKr   r   r   rV   r>   r   r   ú<module>r`      s#  ðð
ð 
ð: Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø €€€Ø Ð Ð Ð Ø €€€Ø Ð Ð Ð Ø €€€Ø €€€Ø %Ð %Ð %Ð %Ð %Ð %ð ˆIÔ˜Xœ\ðIð IØ+5Ô+GðIñ Iô IñJô J€	ð	Fð 	Fð 	Fð 	Fð{(ð {(ð {(ð {(ð {(�f”nñ {(ô {(ð {(ð|ð ð ð ð r   