Format: application/x-python-code
⬇ Download File (5.1 KB)
   1  o
   2  
   3  ��h$�@sxdZddlZddlZddlZddlmZgd�Zdddd	�Zddd�Zd
   4  d�Z	Gdd�d�Z
   5  dd�Zdd�Zdd�Z
   6  dS)a�Hooks for IPython.
   7  
   8  In Python, it is possible to overwrite any method of any object if you really
   9  want to.  But IPython exposes a few 'hooks', methods which are *designed* to
  10  be overwritten by users for customization purposes.  This module defines the
  11  default versions of all such hooks, which get used by IPython if not
  12  overridden by the user.
  13  
  14  Hooks are simple functions, but they should be declared with ``self`` as their
  15  first argument, because when activated they are registered into IPython as
  16  instance methods. The self argument will be the IPython running instance
  17  itself, so hooks have full access to the entire IPython object.
  18  
  19  If you wish to define a new hook and activate it, you can make an :doc:`extension
  20  </config/extensions/index>` or a :ref:`startup script <startup_files>`. For
  21  example, you could use a startup file like this::
  22  
  23      import os
  24  
  25      def calljed(self,filename, linenum):
  26          "My editor hook calls the jed editor directly."
  27          print("Calling my own editor, jed ...")
  28          if os.system('jed +%d %s' % (linenum,filename)) != 0:
  29              raise TryNext()
  30  
  31      def load_ipython_extension(ip):
  32          ip.set_hook('editor', calljed)
  33  
  34  �N���TryNext)�editor�synchronize_with_editor�
  35  show_in_pager�pre_prompt_hook�
  36  clipboard_getz8a callback for the 'pre_execute' or 'pre_run_cell' eventz,a callback for the 'shell_initialized' eventzthe atexit module)Zpre_run_code_hookZlate_startup_hookZ
  37  shutdown_hookTcCs�|j}|dus|dkrd}ndt|�}d|vr(tj�|�r(|ddkr(d|}tjd	|||fd
  38  d�}|r?|��dkrAt��dSdS)aOpen the default editor at the given filename and linenumber.
  39  
  40      This is IPython's default editor hook, you can use it as an example to
  41      write your own modified one.  To set your own editor function as the
  42      new editor hook, call ip.set_hook('editor',yourfunc).NZnotepad�z+%d� r�"z"%s"z%s %s %sT)�shell)	r�int�os�path�isfile�
  43  subprocess�Popen�waitr)�self�filename�linenumrrZlinemark�proc�r�Hc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/hooks.pyr<s	 ��rcCsdS�Nr)rrr�columnrrrrXsrc@s<eZdZdZddd�Zdd�Zdd�Zdd
  44  d�Zdd
  45  �ZdS)�CommandChainDispatcherz� Dispatch calls to a chain of commands until some func can handle it
  46  
  47      Usage: instantiate, execute "add" to add commands (with optional
  48      priority), execute normally via f() calling mechanism.
  49  
  50      NcCs|dur	g|_dS||_dSr)�chain)r�commandsrrr�__init__cs
  51  
  52  zCommandChainDispatcher.__init__cOsVt�}|jD]"\}}z
  53  ||i|��WSty(}z|}WYd}~qd}~ww|�)z� Command chain is called just like normal func.
  54  
  55          This will call all funcs in chain with the same args as were given to
  56          this function, and return the result of first func that didn't raise
  57          TryNextN)rr)r�args�kw�last_exc�prio�cmd�excrrr�__call__js��zCommandChainDispatcher.__call__cC�
  58  t|j�Sr)�strr�rrrr�__str__zs
  59  zCommandChainDispatcher.__str__rcCs&|j�||f�|jjdd�d�dS)z1 Add a func to the cmd chain with given priority cSs|dS)Nrr)�xrrr�<lambda>�sz,CommandChainDispatcher.add.<locals>.<lambda>)�keyN)r�append�sort)r�func�priorityrrr�add}szCommandChainDispatcher.addcCr()zV Return all objects in chain.
  60  
  61          Handy if the objects are not callable.
  62          )�iterrr*rrr�__iter__�s
  63  zCommandChainDispatcher.__iter__r)r)	�__name__�
  64  __module__�__qualname__�__doc__r r'r+r3r5rrrrr\s
  65  
  66  rcCst�)z Run a string through pager r)r�data�startZscreen_linesrrrr�srcCsdS)z� Run before displaying the next prompt
  67  
  68      Use this e.g. to display output from asynchronous operations (in order
  69      to not mess up text entry)
  70      Nrr*rrrr�src	Cslddlm}m}m}m}tjdkr||g}ntjdkr ||g}n||g}t�}|D]}|�|�q)|�}|S)z" Get text from the clipboard.
  71      �)�osx_clipboard_get�tkinter_clipboard_get�win32_clipboard_get�wayland_clipboard_get�win32�darwin)	Z
  72  lib.clipboardr=r>r?r@�sys�platformrr3)	rr=r>r?r@r�
  73  dispatcherr1�textrrrr	�s
  74  
  75  
  76  
  77  r	)NT)r9rrrC�errorr�__all__�
  78  deprecatedrrrrrr	rrrr�<module>s %�
  79  .
  80