
    ^h                     F    S r SSKJr  SSKJrJr  SSKJr   " S S\5      rg)z)ZMQ Kernel History accessor and manager.     )HistoryAccessorBase)DictList)Emptyc                       \ rS rSrSr\" S/5      r\" 5       r\" 5       r	\" 5       r
S rSS jrSS jr  SS jrSS	 jrSS
 jrS rSS jrSrg)ZMQHistoryManager   z2History accessor and manager for ZMQ-based kernels c                     Xl         g)z
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   s     T/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_console/zmqhistory.py__init__ZMQHistoryManager.__init__   s	         c                 <   / n[        U R                  S5      (       am  U R                  R                  " SXUS.UD6n  U R                  R                  SS9nUS   R	                  S5      U:X  a  US   R	                  S/ 5      n U$  MM  U$ ! [
         a     U$ f = f)	zr
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_type   )timeoutparent_headermsg_idcontent )hasattrr   r   get_shell_msggetr   )r   r   r   r   kwargsr   r   replys           r   _load_historyZMQHistoryManager._load_history(   s     4;;	**[[(( 3S:J3+13F  KK55a5@E _-11(;vE"'	"2"6"6y""E F    
 s   B 
BBc                 $    U R                  SXUS9$ )Ntail)r   nr   r   r#   )r   r'   r   r   include_latests        r   get_tailZMQHistoryManager.get_tail?   s!    !!6Q)/ " 1 	1r   Nc           
      (    U R                  SUX#XEUS9$ )Nsearch)r   patternr   
search_rawr   r'   uniquer(   )r   r.   r   r/   r   r'   r0   s          r   r-   ZMQHistoryManager.searchC   s(    !!8W&))/V " E 	Er   c           	      (    U R                  SUXRUUS9$ )Nrange)r   r   r   startstopsessionr(   )r   r6   r4   r5   r   r   s         r   	get_rangeZMQHistoryManager.get_rangeI   s&    !!7)/4*1 " 3 	3r   c                 $    U R                  SUX1S9$ )Nr3   )r   r   r   rangestrr(   )r   r:   r   r   s       r   get_range_by_str"ZMQHistoryManager.get_range_by_strN   s#    !!7)/ " D 	Dr   c                     gz(
Nothing to do for ZMQ-based histories.
Nr   )r   s    r   end_sessionZMQHistoryManager.end_sessionR        	r   c                     gr>   r   )r   new_sessions     r   resetZMQHistoryManager.resetX   rA   r   r   )TFr3   )
   TFF)*TTFNF)r   NTF)TF)T)__name__
__module____qualname____firstlineno____doc__r   input_hist_parsedr   output_histdir_histoutput_hist_reprsr   r#   r*   r-   r7   r;   r?   rD   __static_attributes__r   r   r   r   r      sY    <bT
&KvH.1 8<,1E3
Dr   r   N)	rL   IPython.core.historyr   	traitletsr   r   queuer   r   r   r   r   <module>rU      s"    0 5   H+ Hr   