
    Xhw                     B    d Z ddlmZ ddlmZ ddlmZ  G d de      Zy)z7Adapt readline completer interface to make ZMQ request.    )Configurable)Float)run_syncc                   @     e Zd ZdZ eddd      Zd fd	Zd Z x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helpc                 X    t         t        |   |       || _        || _        g | _        y )N)r   )superr   __init__shellclientmatches)selfr   r   r   	__class__s       M/var/www/html/myenv/lib/python3.12/site-packages/jupyter_console/completer.pyr   zZMQCompleter.__init__   s*    l4))8
    c                     | j                   j                  ||      } t        | j                   j                  j                        | j
                        }|d   d   |k(  r|d   S g ddi ddS )	N)code
cursor_pos)timeoutparent_headermsg_idcontentr   ok)r   cursor_start
cursor_endmetadatastatus)r   completer   shell_channelget_msgr   )r   r   r   r   msgs        r   complete_requestzZMQCompleter.complete_request   s|     %%! & 

 :ht{{00889$,,O)V3y>!q$0 	0r   )N)	__name__
__module____qualname____doc__r   r   r   r$   __classcell__)r   s   @r   r   r      s#    5 C+LMG0r   r   N)r(   traitlets.configr   	traitletsr   jupyter_console.utilsr   r    r   r   <module>r.      s    =
 *  *0< 0r   