B
    [                 @   sb   d Z yddlmZ W n  ek
r4   ddlmZ Y nX ddlmZ ddlmZ G dd deZ	dS )z7Adapt readline completer interface to make ZMQ request.    )Empty)Configurable)Floatc                   s8   e Zd ZdZeddddZd fdd	Zd	d
 Z  ZS )ZMQCompleterzClient-side completion machinery.

    How it works: self.complete will be called multiple times, with
    state=0,1,2,... When state=0 it should compute ALL the completion matches,
    and then return them for each value of state.g      @Tztimeout before completion abort)confighelpNc                s(   t t| j|d || _|| _g | _d S )N)r   )superr   __init__shellclientmatches)selfr
   r   r   )	__class__ 8lib/python3.7/site-packages/jupyter_console/completer.pyr	      s    zZMQCompleter.__init__c             C   sJ   | j j||d}| j jj| jd}|d d |kr:|d S g ddi ddS )	N)code
cursor_pos)timeoutZparent_headermsg_idZcontentr   ok)r   Zcursor_startZ
cursor_endZmetadataZstatus)r   ZcompleteZshell_channelZget_msgr   )r   r   r   r   msgr   r   r   complete_request   s    zZMQCompleter.complete_request)N)	__name__
__module____qualname____doc__r   r   r	   r   __classcell__r   r   )r   r   r      s   r   N)
r   Zqueuer   ImportErrorZQueueZtraitlets.configr   Z	traitletsr   r   r   r   r   r   <module>   s   