§
    �Ÿj2  ã                   óŠ   — d 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 ddlmZ  G d„ de¦  «        Z G d„ d	e¦  «        ZdS )
zaDisplayhook for IPython.

This defines a callable class that IPython uses for `sys.displayhook`.
é    N)ÚConfigurable)ÚInstanceÚFloat)Úwarnc                   óò   ‡ — e Zd ZdZ edd¬¦  «        Z edd¬¦  «        Z ed¦  «        Zdˆ fd	„	Z	e
d
„ ¦   «         Zd„ Zd„ Zed„ ¦   «         Zd„ Zd„ Zd„ ZdZddd„Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ Zd„ Zˆ xZS )ÚDisplayHookzÅThe custom IPython displayhook to replace sys.displayhook.

    This class does many things, but the basic idea is that it is a callable
    that gets called anytime user code returns a value.
    z1IPython.core.interactiveshell.InteractiveShellABCT)Ú
allow_nonez-IPython.core.interactiveshell.ExecutionResultgš™™™™™É?Néè  c                 ót  •—  t          t          | ¦  «        j        d	d|i|¤Ž d}|dk    r
d| _        d}n+||k     rd| _        d}t	          d|z  d¬¦  «         nd| _        || _        || _        d\  | _        | _        | _	        | j        | j        | j	        dœ}| j        j
                             |¦  «         d S )
NÚshellé   r   z6caching was disabled (min value for cache size is %s).)Ú
stacklevelé   ©Ú r   r   ©Ú_Ú__Ú___© )Úsuperr   Ú__init__Údo_full_cacher   Ú
cache_sizer   r   r   r   Úuser_nsÚupdate)Úselfr   r   ÚkwargsÚcache_size_minÚ
to_user_nsÚ	__class__s         €úe/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/IPython/core/displayhook.pyr   zDisplayHook.__init__$   sì   ø€ Ø)��k˜4Ñ Ô Ô)Ð@Ð@°Ð@¸Ð@Ð@Ð@ØˆØ˜Š?ˆ?Ø!"ˆDÔØˆJˆJØ˜.Ò(Ð(Ø!"ˆDÔØˆJÝÐIØñ Ø+,ð.ñ .ô .ð .ð .ð "#ˆDÔà$ˆŒð ˆŒ
à"*ÑˆŒˆtŒw�t”xð œ& d¤g°D´HÐ=Ð=ˆ
ØŒ
Ô×!Ò! *Ñ-Ô-Ð-Ð-Ð-ó    c                 ó   — | j         j        S ©N)r   Úexecution_count©r   s    r"   Úprompt_countzDisplayHook.prompt_count=   s   € àŒzÔ)Ð)r#   c                 óž   — dt           j        v r>	 | j        j        d         }|| j        urdS | j        j        d= dS # t
          $ r Y dS w xY wdS )z3Check if the user has set the '_' variable by hand.r   N)Úbuiltin_modÚ__dict__r   r   r   ÚKeyError)r   Ú
user_values     r"   Úcheck_for_underscorez DisplayHook.check_for_underscoreF   su   € ð
 •+Ô&Ð&Ð&ðØ!œZÔ/°Ô4�
Ø T¤VÐ+Ð+Ø�FØ”JÔ& sÐ+Ð+Ð+øÝð ð ð Ø��ðøøøð 'Ð&s   �< ­< ¼
A
Á	A
c                 ó€   — 	 | j         j        j        d         }n# t          $ r Y dS w xY w|                      |¦  «        S )z2Should we silence the display hook because of ';'?éÿÿÿÿF)r   Úhistory_managerÚinput_hist_parsedÚ
IndexErrorÚsemicolon_at_end_of_expression)r   Úcells     r"   ÚquietzDisplayHook.quietT   sS   € ð	Ø”:Ô-Ô?ÀÔCˆDˆDøÝð 	ð 	ð 	à�5�5ð	øøøð ×2Ò2°4Ñ8Ô8Ð8s   ‚ š
(§(c                 óZ  — t          j        | ¦  «        }t          t          j        |j        ¦  «        ¦  «        }t          |¦  «        D ]`}|d         t          j        t          j        t          j	        t          j
        fv rŒ9|d         t          j        k    r|d         dk    r dS  dS dS )z=Parse Python expression and detects whether last token is ';'r   r   ú;TFN)Ú_ioÚStringIOÚlistÚtokenizeÚgenerate_tokensÚreadlineÚreversedÚ	ENDMARKERÚNLÚNEWLINEÚCOMMENTÚOP)Ú
expressionÚsioÚtokensÚtokens       r"   r4   z*DisplayHook.semicolon_at_end_of_expression`   sŸ   € õ Œl˜:Ñ&Ô&ˆÝ•hÔ.¨s¬|Ñ<Ô<Ñ=Ô=ˆå˜fÑ%Ô%ð 	ð 	ˆEØ�QŒx�HÔ.µ´½XÔ=MÍxÔO_Ð`Ð`Ð`ØØ�a”�HœKÒ'Ð'¨e°A¬h¸#ªo¨oØ�t�tà�u�uð	ð 	r#   c                 ó   — dS )z.Start the displayhook, initializing resources.Nr   r'   s    r"   Ústart_displayhookzDisplayHook.start_displayhooko   s   € àˆr#   c                 óæ   — t           j                             | j        j        ¦  «         d                     | j        j        ¦  «        }| j        r!t           j                             |¦  «         dS dS )zyWrite the output prompt.

        The default implementation simply writes the prompt to
        ``sys.stdout``.
        z	Out[{}]: N)ÚsysÚstdoutÚwriter   Úseparate_outÚformatr&   r   )r   Ú	outprompts     r"   Úwrite_output_promptzDisplayHook.write_output_prompts   sh   € õ 	Œ
×Ò˜œÔ0Ñ1Ô1Ð1Ø×&Ò& t¤zÔ'AÑBÔBˆ	ØÔð 	(ÝŒJ×Ò˜YÑ'Ô'Ð'Ð'Ð'ð	(ð 	(r#   c                 ó@   — | j         j                             |¦  «        S )a÷  Compute format data of the object to be displayed.

        The format data is a generalization of the :func:`repr` of an object.
        In the default implementation the format data is a :class:`dict` of
        key value pair where the keys are valid MIME types and the values
        are JSON'able data structure containing the raw data for that MIME
        type. It is up to frontends to determine pick a MIME to to use and
        display that data in an appropriate manner.

        This method only computes the format data for the object and should
        NOT actually print or write that to a stream.

        Parameters
        ----------
        result : object
            The Python object passed to the display hook, whose format will be
            computed.

        Returns
        -------
        (format_dict, md_dict) : dict
            format_dict is a :class:`dict` whose keys are valid MIME types and values are
            JSON'able raw data for that MIME type. It is recommended that
            all return values of this should always include the "text/plain"
            MIME type representation of the object.
            md_dict is a :class:`dict` with the same MIME type keys
            of metadata associated with each output.

        )r   Údisplay_formatterrP   ©r   Úresults     r"   Úcompute_format_datazDisplayHook.compute_format_data   s   € ð< ŒzÔ+×2Ò2°6Ñ:Ô:Ð:r#   FÚreturnc                 ó,  — d|vrdS |d         }d|v r| j         sd|z   }	 t          |¦  «         dS # t          $ rX t          |                     t          j        j        d¦  «                             t          j        j        ¦  «        ¦  «         Y dS w xY w)a  Write the format data dict to the frontend.

        This default version of this method simply writes the plain text
        representation of the object to ``sys.stdout``. Subclasses should
        override this method to send the entire `format_dict` to the
        frontends.

        Parameters
        ----------
        format_dict : dict
            The format dict for the object passed to `sys.displayhook`.
        md_dict : dict (optional)
            The metadata dict to be associated with the display data.
        ú
text/plainNú
Úbackslashreplace)Úprompt_end_newlineÚprintÚUnicodeEncodeErrorÚencoderL   rM   ÚencodingÚdecode)r   Úformat_dictÚmd_dictÚresult_reprs       r"   Úwrite_format_datazDisplayHook.write_format_data¢   s¿   € ð ˜{Ð*Ð*àˆFð " ,Ô/ˆØ�;ÐÐð Ô*ð 1à" [Ñ0�ð	jÝ�+ÑÔÐÐÐøÝ!ð 	jð 	jð 	jõ �+×$Ò$¥S¤ZÔ%8Ð9KÑLÔL×SÒSÕTWÔT^ÔTgÑhÔhÑiÔiÐiÐiÐiÐið	jøøøs    1 ±ABÂBc                 óè  — | j         �re|| j        j        d         u�rRt          | j        j        d         ¦  «        | j         k    r| j        r|                      ¦   «          d}d„ t          dd¦  «        D ¦   «         D ]B}|| j        j        vrŒt          | |¦  «        | j        j                             |¦  «        urd}ŒC| j	        | _
        | j        | _	        || _        dt          j        vr1|r/| j                             | j        | j	        | j
        dœd¬	¦  «         i }| j        rKd
| j        z  }|||<   | j                             |d¬	¦  «         || j        j        d         | j        <   dS dS dS dS )z7Update user_ns with various things like _, __, _1, etc.Ú_ohTc                 ó   — g | ]}d |z  ‘ŒS )r   r   )Ú.0Úis     r"   ú
<listcomp>z.DisplayHook.update_user_ns.<locals>.<listcomp>Ø   s   € Ð5Ð5Ð5 Q˜3˜q™5Ð5Ð5Ð5r#   r   é   Fr   r   )Úinteractivez_%sN)r   r   r   Úlenr   Ú
cull_cacheÚrangeÚgetattrÚgetr   r   r   r*   r+   Úpushr(   )r   rV   Úupdate_undersÚundersÚto_mainÚ
new_results         r"   Úupdate_user_nszDisplayHook.update_user_nsË   s«  € ð Œ?ñ 	F˜v¨T¬ZÔ-?ÀÔ-FÐFÑFÝ�4”:Ô% eÔ,Ñ-Ô-°´Ò@Ð@ÀTÔEWÐ@Ø—’Ñ!Ô!Ð!ð !ˆMØ5Ð5­%°°!©*¬*Ð5Ñ5Ô5ð *ð *�Ø ¤Ô!3Ð3Ð3ØÝ˜4 Ñ(Ô(°´
Ô0B×0FÒ0FÀvÑ0NÔ0NÐNÐNØ$)�Møà”wˆDŒHØ”fˆDŒGØˆDŒFà�;Ô/Ð/Ð/°mÐ/Ø”
—’ T¤VØ&*¤gØ&*¤hð!0ð !0à=Bð  ñ Dô Dð Dð
 ˆGØÔ!ð FØ" TÔ%6Ñ6�
Ø&,�˜
Ñ#Ø”
—’ °U�Ñ;Ô;Ð;Ø?E�”
Ô" 5Ô)¨$Ô*;Ñ<Ð<Ð<ð=	Fð 	FÐFÐFð4Fð Fr#   c                 ó0   — | j         �|| j         _        d S d S r%   )Úexec_resultrV   rU   s     r"   Úfill_exec_resultzDisplayHook.fill_exec_resultï   s$   € ØÔÐ'Ø&,ˆDÔÔ#Ð#Ð#ð (Ð'r#   c                 ó¾   — d|vrdS | j         j        j        r&| j         j                             |d         d¦  «         |d         | j         j        j        | j        <   dS )zLog the output.rZ   NÚoutput)r   ÚloggerÚ
log_outputÚ	log_writer1   Úoutput_hist_reprsr(   )r   rc   s     r"   r€   zDisplayHook.log_outputó   sf   € à˜{Ð*Ð*àˆFØŒ:ÔÔ'ð 	MØŒJÔ×'Ò'¨°LÔ(AÀ8ÑLÔLÐLà4?ÀÔ4Mð 	Œ
Ô"Ô4°TÔ5FÑGÐGÐGr#   c                 ó”   — t           j                             | j        j        ¦  «         t           j                             ¦   «          dS )z%Finish up all displayhook activities.N)rL   rM   rN   r   Úseparate_out2Úflushr'   s    r"   Úfinish_displayhookzDisplayHook.finish_displayhooký   s7   € åŒ
×Ò˜œÔ1Ñ2Ô2Ð2ÝŒ
×ÒÑÔÐÐÐr#   c                 ó¸  — |                       ¦   «          |�Á|                      ¦   «         s¯|                      ¦   «          |                      ¦   «          |                      |¦  «        \  }}|                      |¦  «         |                      |¦  «         |r+|                      ||¦  «         |                      |¦  «         |  	                    ¦   «          dS dS dS )z¼Printing with history cache management.

        This is invoked every time the interpreter needs to print, and is
        activated by setting the variable sys.displayhook to it.
        N)
r.   r6   rJ   rR   rW   ry   r|   rf   r€   r†   ©r   rV   rc   rd   s       r"   Ú__call__zDisplayHook.__call__  sã   € ð 	×!Ò!Ñ#Ô#Ð#ØÐ d§j¢j¡l¤lÐØ×"Ò"Ñ$Ô$Ð$Ø×$Ò$Ñ&Ô&Ð&Ø#'×#;Ò#;¸FÑ#CÔ#CÑ ˆK˜Ø×Ò Ñ'Ô'Ð'Ø×!Ò! &Ñ)Ô)Ð)Øð -Ø×&Ò& {°GÑ<Ô<Ð<Ø—’ Ñ,Ô,Ð,Ø×#Ò#Ñ%Ô%Ð%Ð%Ð%ð ÐÐÐr#   c                 ó¾  — | j         j                             di ¦  «        }t          |¦  «        }t	          t          || j        z  ¦  «        d¦  «        }t          d                     ||¬¦  «        ¦  «         t          t          |¦  «        ¦  «        D ]G\  }}||k    r dS | j         j                             d|z  d¦  «         |                     |d¦  «         ŒHdS )z-Output cache is full, cull the oldest entriesrh   é   zVOutput cache limit (currently {sz} entries) hit.
Flushing oldest {cull_count} entries.)ÚszÚ
cull_countz_%iN)r   r   rs   ro   ÚmaxÚintÚcull_fractionr   rP   Ú	enumerateÚsortedÚpop)r   ÚohrŒ   r�   rk   Úns         r"   rp   zDisplayHook.cull_cache  sà   € àŒZÔ×#Ò# E¨2Ñ.Ô.ˆÝ�‰WŒWˆÝ�˜R $Ô"4Ñ4Ñ5Ô5°qÑ9Ô9ˆ
Ýð 5ß5;²V¸rÈj°VÑ5YÔ5Yñ	[ô 	[ð 	[õ �f R™jœjÑ)Ô)ð 	ð 	‰DˆAˆqØ�JŠˆØ��ØŒJÔ×"Ò" 5¨1¡9¨dÑ3Ô3Ð3Ø�FŠF�1�d‰OŒOˆOˆOð		ð 	r#   c                 ó   — | j         st          d¦  «        ‚t          d| j        dz   ¦  «        D ])}dt	          |¦  «        z   }	 | j        j        |= Œ##  Y Œ'xY w| j        j                             dd ¦  «        }|�|                     ¦   «          d\  | _	        | _
        | _        dt          j        vr2| j        j                             | j	        | j
        | j        dœ¦  «         dd l}t           j        dk    r|                     ¦   «          d S d S )	NzJYou shouldn't have reached the cache flush if full caching is not enabled!r   r   rh   r   r   r   Úcli)r   Ú
ValueErrorrq   r(   Úreprr   r   rs   Úclearr   r   r   r*   r+   r   ÚgcrL   ÚplatformÚcollect)r   r•   Úkeyr”   r›   s        r"   r…   zDisplayHook.flush#  s$  € ØÔ!ð 	@Ýð ?ñ @ô @ð @õ �q˜Ô*¨QÑ.Ñ/Ô/ð 	ð 	ˆAØ•d˜1‘g”g‘+ˆCðØ”JÔ& sÐ+Ð+øØ�D�Døøøð ŒZÔ×#Ò# E¨4Ñ0Ô0ˆØˆ>Ø�HŠH‰JŒJˆJð %/Ñ!ˆŒ�”˜œà•kÔ*Ð*Ð*ØŒJÔ×%Ò%¨4¬6°t´wÀTÄXÐ&NÐ&NÑOÔOÐOØˆ	ˆ	ˆ	õ Œ<˜5Ò Ð Ø�JŠJ‰LŒLˆLˆLˆLð !Ð s   ÁAÁA)Nr
   r%   )rX   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r{   r   r�   r   Úpropertyr(   r.   r6   Ústaticmethodr4   rJ   rR   rW   r]   rf   ry   r|   r€   r†   r‰   rp   r…   Ú__classcell__)r!   s   @r"   r   r      s¬  ø€ € € € € ðð ð ˆHÐHØ $ð&ñ &ô &€Eà�(ÐJØ&*ð,ñ ,ô ,€Kà�E˜#‘J”J€Mð.ð .ð .ð .ð .ð .ð2 ð*ð *ñ „Xð*ðð ð ð
9ð 
9ð 
9ð ðð ñ „\ððð ð ð
(ð 
(ð 
(ð;ð ;ð ;ðB Ðð'jð 'jð 'jð 'jð 'jðR"Fð "Fð "FðH-ð -ð -ðNð Nð Nðð ð ð
&ð &ð &ð &ð$ð ð ðð ð ð ð ð ð r#   r   c                   ó   — e Zd Zdd„Zdd„ZdS )ÚCapturingDisplayHookNc                 ó*   — || _         |€g }|| _        d S r%   )r   Úoutputs)r   r   r©   s      r"   r   zCapturingDisplayHook.__init__A  s   € ØˆŒ
Øˆ?ØˆGØˆŒˆˆr#   c                 óŒ   — |€d S | j         j                             |¦  «        \  }}| j                             ||dœ¦  «         d S )N)ÚdataÚmetadata)r   rT   rP   r©   Úappendrˆ   s       r"   r‰   zCapturingDisplayHook.__call__G  sM   € Øˆ>ØˆFØ#œzÔ;×BÒBÀ6ÑJÔJÑˆ�WØŒ×Ò k¸wÐHÐHÑIÔIÐIÐIÐIr#   r%   )rŸ   r    r¡   r   r‰   r   r#   r"   r§   r§   @  sB   € € € € € ðð ð ð ðJð Jð Jð Jð Jð Jr#   r§   )r¢   Úbuiltinsr*   rL   Úior9   r<   Útraitlets.config.configurabler   Ú	traitletsr   r   Úwarningsr   r   Úobjectr§   r   r#   r"   ú<module>r´      sè   ððð ð Ð Ð Ð Ø 
€
€
€
Ø Ð Ð Ð Ø €€€à 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð ðfð fð fð fð f�,ñ fô fð fðR	Jð Jð Jð Jð J˜6ñ Jô Jð Jð Jð Jr#   