
    ChL                        S r SSKJr  SSKrSSKrSSKrSSKJr  SSK	J
r
Jr  SSKJrJrJr  SSKJrJr   " S S	5      r " S
 S\5      rg)z7Replacements for sys.displayhook that publish over ZMQ.    )annotationsN)DisplayHook)Sessionextract_header)AnyDictInstance)encode_images
json_cleanc                  4    \ rS rSrSrSrS rS rS rS r	Sr
g	)
ZMQDisplayHook   zKA simple displayhook that publishes the object's repr over a ZeroMQ
socket.s   execute_resultc                *    Xl         X l        0 U l        g)zInitialize the hook.N)session
pub_socketparent_header)selfr   r   s      hC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\ipykernel/displayhook.py__init__ZMQDisplayHook.__init__   s    $    c                    g)z$This method is replaced in kernelappr    r   s    r   get_execution_count"ZMQDisplayHook.get_execution_count   s    r   c                L   Uc  gU[         l        [        R                  R	                  5         [        R
                  R	                  5         U R                  5       S[        U5      00 S.nU R                  R                  U R                  SX R                  U R                  S9  g)zHandle a hook call.Nz
text/plain)execution_countdatametadataexecute_result)parentident)builtins_sysstdoutflushstderrr   reprr   sendr   r   topic)r   objcontentss      r   __call__ZMQDisplayHook.__call__"   s    ;




#779!49-

 	OO-x@R@RZ^ZdZd 	 	
r   c                $    [        U5      U l        g)zSet the parent header.Nr   r   r   r"   s     r   
set_parentZMQDisplayHook.set_parent3       +F3r   )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r,   r   r   r/   r4   __static_attributes__r   r   r   r   r      s"     E 
"4r   r   c                  t    \ rS rSr% SrSr\" \SS9r\	" SS9r
\" 0 5      rS\S'   S rS	 rS
 rSS jrS rSrg)ZMQShellDisplayHook8   zA displayhook subclass that publishes data using ZeroMQ. This is intended
to work with an InteractiveShell instance. It sends a dict of different
representations of the object.NT)
allow_nonezdict[str, t.Any] | Nonemsgc                $    [        U5      U l        g)z%Set the parent for outbound messages.Nr2   r3   s     r   r4   ZMQShellDisplayHook.set_parentD   r6   r   c                    U R                   (       a.  U R                   R                  S0 0 S.U R                  S9U l        gg)zStart the display hook.r!   )r   r    )r"   N)r   rA   r   r   s    r   start_displayhook%ZMQShellDisplayHook.start_displayhookH   sB    <<||''  " )) ( DH r   c                `    U R                   (       a  U R                  U R                   S   S'   gg)zWrite the output prompt.contentr   N)rA   prompt_countr   s    r   write_output_prompt'ZMQShellDisplayHook.write_output_promptT   s(    88595F5FDHHY 12 r   c                    U R                   (       a6  [        [        U5      5      U R                   S   S'   X R                   S   S'   gg)z!Write format data to the message.rH   r   r    N)rA   r   r
   )r   format_dictmd_dicts      r   write_format_data%ZMQShellDisplayHook.write_format_dataY   s<    88*4];5O*PDHHY'.5HHY
+ r   c                n   [         R                  R                  5         [         R                  R                  5         U R                  (       aa  U R                  S   S   (       aJ  U R
                  (       a9  U R
                  R                  U R                  U R                  U R                  S9  SU l        g)z%Finish up all displayhook activities.rH   r   )r#   N)	r&   r'   r(   r)   rA   r   r+   r   r,   r   s    r   finish_displayhook&ZMQShellDisplayHook.finish_displayhook_   sk    



88+F3LLdootxxtzzJr   )rA   r   )N)r7   r8   r9   r:   r;   r,   r	   r   r   r   r   r   r   __annotations__r4   rE   rJ   rO   rR   r<   r   r   r   r>   r>   8   sM    & Ew40G%JHM	  4
G
6r   r>   )r;   
__future__r   r$   r&   typingtIPython.core.displayhookr   jupyter_client.sessionr   r   	traitletsr   r   r	   ipykernel.jsonutilr
   r   r   r>   r   r   r   <module>r\      s<    = #  
  0 : ) ) 8#4 #4L-+ -r   