o
    Zh                     @   s   d Z ddlZddlmZmZmZmZ ddlmZ ddl	m
Z
 zddlmZ W n ey5   ddlmZ Y nw ddlmZmZ ejded	d
 G dd deZdd ZdS )z/Publishing native (typically pickled) objects.
    N)AnyCBytesDictInstance)Configurable)
json_clean)serialize_object)Sessionextract_headerDipykernel.datapub is deprecated. It has moved to ipyparallel.datapub   
stacklevelc                   @   sJ   e Zd ZdZed ZZeeddZe	ddZ
ei Zdd Zdd Zd	S )
ZMQDataPublisherzA zmq data publisher.s   datapubT)
allow_nonec                 C   s   t || _dS )z%Set the parent for outbound messages.N)r
   parent_header)selfparent r   H/var/www/html/lang_env/lib/python3.10/site-packages/ipykernel/datapub.py
set_parent&   s   zZMQDataPublisher.set_parentc                 C   sZ   | j }|dus	J t||j|jd}ttt| d}|j| j	d|| j
|| jd dS )zpublish a data_message on the IOPub channel

        Parameters
        ----------
        data : dict
            The data to be published. Think of it as a namespace.
        N)buffer_thresholditem_threshold)keysZdata_message)contentr   buffersident)sessionr   r   r   r   dictlistr   send
pub_socketr   topic)r   datar   r   r   r   r   r   publish_data*   s    
zZMQDataPublisher.publish_dataN)__name__
__module____qualname____doc__r   r"   r   r	   r   r   r!   r   r   r   r$   r   r   r   r   r      s    
r   c                 C   s0   t jdtdd ddlm} | j|  dS )zpublish a data_message on the IOPub channel

    Parameters
    ----------
    data : dict
        The data to be published. Think of it as a namespace.
    r   r   r   r   )ZMQInteractiveShellN)warningswarnDeprecationWarningZipykernel.zmqshellr)   instanceZdata_pubr$   )r#   r)   r   r   r   r$   D   s   r$   )r(   r*   Z	traitletsr   r   r   r   Ztraitlets.configr   Zipykernel.jsonutilr   Zipyparallel.serializer   ImportErrorZipykernel.serializeZjupyter_client.sessionr	   r
   r+   r,   r   r$   r   r   r   r   <module>   s$   &