
    MhI                     j    d Z ddlZddlZddlZddlmZ g dZddZd Z G d	 d
          Z	d Z
d ZdS )a  Hooks for IPython.

In Python, it is possible to overwrite any method of any object if you really
want to.  But IPython exposes a few 'hooks', methods which are *designed* to
be overwritten by users for customization purposes.  This module defines the
default versions of all such hooks, which get used by IPython if not
overridden by the user.

Hooks are simple functions, but they should be declared with ``self`` as their
first argument, because when activated they are registered into IPython as
instance methods. The self argument will be the IPython running instance
itself, so hooks have full access to the entire IPython object.

If you wish to define a new hook and activate it, you can make an :doc:`extension
</config/extensions/index>` or a :ref:`startup script <startup_files>`. For
example, you could use a startup file like this::

    import os

    def calljed(self,filename, linenum):
        "My editor hook calls the jed editor directly."
        print("Calling my own editor, jed ...")
        if os.system('jed +%d %s' % (linenum,filename)) != 0:
            raise TryNext()

    def load_ipython_extension(ip):
        ip.set_hook('editor', calljed)

    N   TryNext)editorsynchronize_with_editorshow_in_pagerclipboard_getTc                 F   | j         }||dk    rd}ndt          |          z  }d|v r0t          j                            |          r|d         dk    rd|z  }t          j        |d|d|d	
          }|r&|                                dk    rt                      dS dS )a  Open the default editor at the given filename and linenumber.

    This is IPython's default editor hook, you can use it as an example to
    write your own modified one.  To set your own editor function as the
    new editor hook, call ip.set_hook('editor',yourfunc).Nnotepad z+%d r   "z"%s"T)shell)	r   intospathisfile
subprocessPopenwaitr   )selffilenamelinenumr   r   linemarkprocs          R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/core/hooks.pyr   r   6   s     [F &)++3w<<' f}}//}F1I4D4D& &&&(((HHE"&( ( (D 		q  ii       c                     d S N )r   r   r   columns       r   r   r   R   s    r   c                   4    e Zd ZdZd	dZd Zd Zd
dZd ZdS )CommandChainDispatcherz Dispatch calls to a chain of commands until some func can handle it

    Usage: instantiate, execute "add" to add commands (with optional
    priority), execute normally via f() calling mechanism.

    Nc                 *    |	g | _         d S || _         d S r   )chain)r   commandss     r   __init__zCommandChainDispatcher.__init__]   s    DJJJ!DJJJr   c                     t                      }| j        D ](\  }}	  ||i |c S # t           $ r}|}Y d}~!d}~ww xY w|)z Command chain is called just like normal func.

        This will call all funcs in chain with the same args as were given to
        this function, and return the result of first func that didn't raise
        TryNextN)r   r%   )r   argskwlast_excpriocmdexcs          r   __call__zCommandChainDispatcher.__call__d   sw     99
 	 	HDsD'B'''''    s   &
<7<c                 *    t          | j                  S r   )strr%   r   s    r   __str__zCommandChainDispatcher.__str__t   s    4:r   r   c                 v    | j                             ||f           | j                             d            dS )z1 Add a func to the cmd chain with given priority c                     | d         S )Nr   r    )xs    r   <lambda>z,CommandChainDispatcher.add.<locals>.<lambda>z   s
    ad r   )keyN)r%   appendsort)r   funcprioritys      r   addzCommandChainDispatcher.addw   s;    
8T*+++
NN+++++r   c                 *    t          | j                  S )zV Return all objects in chain.

        Handy if the objects are not callable.
        )iterr%   r2   s    r   __iter__zCommandChainDispatcher.__iter__|   s    
 DJr   r   )r   )	__name__
__module____qualname____doc__r'   r/   r3   r=   r@   r    r   r   r#   r#   V   ss         " " " "     , , , ,
         r   r#   c                     t           )z Run a string through pager r   )r   datastartscreen_liness       r   r   r      s	     Mr   c                     ddl m}m}m}m} t
          j        dk    r||g}nt
          j        dk    r||g}n||g}t                      }|D ]}|                    |            |            }|S )z" Get text from the clipboard.
       )osx_clipboard_gettkinter_clipboard_getwin32_clipboard_getwayland_clipboard_getwin32darwin)	lib.clipboardrK   rL   rM   rN   sysplatformr#   r=   )	r   rK   rL   rM   rN   r%   
dispatcherr;   texts	            r   r	   r	      s                |w$&;<		!	!"$9:&(=>'))J  t:<<DKr   )NT)rD   r   r   rR   errorr   __all__r   r   r#   r   r	   r    r   r   <module>rX      s    J 
			     



      
     8  +  +  +  +  +  +  +  + \      r   