Format: application/x-python-code
1 o
2
3 ��h$ � @ sx d Z ddlZddlZddlZddlmZ g d�Zdddd �Zddd�Zd
4 d� Z G dd� d�Z
5 dd� Zdd� Zdd� 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_hookTc C s� | j }|du s|dkrd}ndt|� }d|v r(tj�|�r(|d dkr(d| }tjd |||f d
38 d�}|r?|�� dkrAt� �dS dS )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�linenumr r Zlinemark�proc� r �Hc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/hooks.pyr <