o
    tf                     @   s@   d Z ddlmZ ddlmZmZ ddlmZ G dd deZdS )z* ZMQ Kernel History accessor and manager.     )HistoryAccessorBase)DictList)Emptyc                   @   s|   e Zd ZdZedgZe Ze Ze Z	dd Z
ddd	ZdddZ		dddZdddZdddZdd ZdddZdS ) ZMQHistoryManagerz2History accessor and manager for ZMQ-based kernels c                 C   s
   || _ dS )a  
        Class to load the command-line history from a ZMQ-based kernel,
        and access the history.

        Parameters
        ----------

        client: `IPython.kernel.KernelClient`
          The kernel client in order to request the history.
        N)client)selfr    r
   c/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/jupyter_console/zmqhistory.py__init__   s   
zZMQHistoryManager.__init__TFrangec                 K   s   g }t | jdr?| jjd
|||d|}	 z	| jjdd}W n
 ty)   Y |S w |d d|kr>|d dg }	 |S q|S )z
        Load the history over ZMQ from the kernel. Wraps the history
        messaging with loop to wait to get history results.
        history)rawoutputhist_access_typeT   )timeoutZparent_headermsg_idcontentNr
   )hasattrr   r   Zget_shell_msgr   get)r	   r   r   r   kwargsr   r   Zreplyr
   r
   r   _load_history(   s(   	zZMQHistoryManager._load_history
   c                 C   s   | j d|||dS )Ntail)r   nr   r   r   )r	   r   r   r   Zinclude_latestr
   r
   r   get_tail?   s   
zZMQHistoryManager.get_tail*Nc              	   C   s   | j d||||||dS )Nsearch)r   patternr   
search_rawr   r   uniquer   )r	   r!   r   r"   r   r   r#   r
   r
   r   r    C   s   zZMQHistoryManager.searchr   c                 C   s   | j d|||||dS )Nr   )r   r   r   startstopsessionr   )r	   r&   r$   r%   r   r   r
   r
   r   	get_rangeI   s   zZMQHistoryManager.get_rangec                 C   s   | j d|||dS )Nr   )r   r   r   rangestrr   )r	   r(   r   r   r
   r
   r   get_range_by_strN   s   z"ZMQHistoryManager.get_range_by_strc                 C      dS z8
        Nothing to do for ZMQ-based histories.
        Nr
   )r	   r
   r
   r   end_sessionR      zZMQHistoryManager.end_sessionc                 C   r*   r+   r
   )r	   Znew_sessionr
   r
   r   resetX   r-   zZMQHistoryManager.reset)TFr   )r   TFF)r   TTFNF)r   NTF)TF)T)__name__
__module____qualname____doc__r   Zinput_hist_parsedr   Zoutput_histZdir_histZoutput_hist_reprsr   r   r   r    r'   r)   r,   r.   r
   r
   r
   r   r      s     





r   N)	r2   ZIPython.core.historyr   Z	traitletsr   r   queuer   r   r
   r
   r
   r   <module>   s
    