U
    ҥc                     @   s   d Z ddlZejdedd 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k
r|   dd	lmZ Y nX dd
lmZmZ G dd de
Zdd ZdS )z/Publishing native (typically pickled) objects.
    NDipykernel.datapub is deprecated. It has moved to ipyparallel.datapub   
stacklevel)AnyCBytesDictInstance)Configurable)
json_clean)serialize_object)Sessionextract_headerc                   @   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)Z
allow_nonec                 C   s   t || _dS )z%Set the parent for outbound messages.N)r   parent_header)selfparent r   0lib/python3.8/site-packages/ipykernel/datapub.py
set_parent&   s    zZMQDataPublisher.set_parentc                 C   sN   | 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.
        )buffer_thresholditem_threshold)keysZdata_message)contentr   buffersidentN)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#   C   s    r#   )r'   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   <module>   s    	%