##// END OF EJS Templates
update author email...
Min RK -
Show More
@@ -1,229 +1,229 b''
1 """Hooks for IPython.
1 """Hooks for IPython.
2
2
3 In Python, it is possible to overwrite any method of any object if you really
3 In Python, it is possible to overwrite any method of any object if you really
4 want to. But IPython exposes a few 'hooks', methods which are *designed* to
4 want to. But IPython exposes a few 'hooks', methods which are *designed* to
5 be overwritten by users for customization purposes. This module defines the
5 be overwritten by users for customization purposes. This module defines the
6 default versions of all such hooks, which get used by IPython if not
6 default versions of all such hooks, which get used by IPython if not
7 overridden by the user.
7 overridden by the user.
8
8
9 Hooks are simple functions, but they should be declared with ``self`` as their
9 Hooks are simple functions, but they should be declared with ``self`` as their
10 first argument, because when activated they are registered into IPython as
10 first argument, because when activated they are registered into IPython as
11 instance methods. The self argument will be the IPython running instance
11 instance methods. The self argument will be the IPython running instance
12 itself, so hooks have full access to the entire IPython object.
12 itself, so hooks have full access to the entire IPython object.
13
13
14 If you wish to define a new hook and activate it, you can make an :doc:`extension
14 If you wish to define a new hook and activate it, you can make an :doc:`extension
15 </config/extensions/index>` or a :ref:`startup script <startup_files>`. For
15 </config/extensions/index>` or a :ref:`startup script <startup_files>`. For
16 example, you could use a startup file like this::
16 example, you could use a startup file like this::
17
17
18 import os
18 import os
19
19
20 def calljed(self,filename, linenum):
20 def calljed(self,filename, linenum):
21 "My editor hook calls the jed editor directly."
21 "My editor hook calls the jed editor directly."
22 print "Calling my own editor, jed ..."
22 print "Calling my own editor, jed ..."
23 if os.system('jed +%d %s' % (linenum,filename)) != 0:
23 if os.system('jed +%d %s' % (linenum,filename)) != 0:
24 raise TryNext()
24 raise TryNext()
25
25
26 def load_ipython_extension(ip):
26 def load_ipython_extension(ip):
27 ip.set_hook('editor', calljed)
27 ip.set_hook('editor', calljed)
28
28
29 """
29 """
30
30
31 #*****************************************************************************
31 #*****************************************************************************
32 # Copyright (C) 2005 Fernando Perez. <fperez@colorado.edu>
32 # Copyright (C) 2005 Fernando Perez. <fperez@colorado.edu>
33 #
33 #
34 # Distributed under the terms of the BSD License. The full license is in
34 # Distributed under the terms of the BSD License. The full license is in
35 # the file COPYING, distributed as part of this software.
35 # the file COPYING, distributed as part of this software.
36 #*****************************************************************************
36 #*****************************************************************************
37
37
38 import os
38 import os
39 import subprocess
39 import subprocess
40 import warnings
40 import warnings
41 import sys
41 import sys
42
42
43 from IPython.core.error import TryNext
43 from IPython.core.error import TryNext
44
44
45 # List here all the default hooks. For now it's just the editor functions
45 # List here all the default hooks. For now it's just the editor functions
46 # but over time we'll move here all the public API for user-accessible things.
46 # but over time we'll move here all the public API for user-accessible things.
47
47
48 __all__ = ['editor', 'synchronize_with_editor',
48 __all__ = ['editor', 'synchronize_with_editor',
49 'shutdown_hook', 'late_startup_hook',
49 'shutdown_hook', 'late_startup_hook',
50 'show_in_pager','pre_prompt_hook',
50 'show_in_pager','pre_prompt_hook',
51 'pre_run_code_hook', 'clipboard_get']
51 'pre_run_code_hook', 'clipboard_get']
52
52
53 deprecated = {'pre_run_code_hook': "a callback for the 'pre_execute' or 'pre_run_cell' event",
53 deprecated = {'pre_run_code_hook': "a callback for the 'pre_execute' or 'pre_run_cell' event",
54 'late_startup_hook': "a callback for the 'shell_initialized' event",
54 'late_startup_hook': "a callback for the 'shell_initialized' event",
55 'shutdown_hook': "the atexit module",
55 'shutdown_hook': "the atexit module",
56 }
56 }
57
57
58 def editor(self, filename, linenum=None, wait=True):
58 def editor(self, filename, linenum=None, wait=True):
59 """Open the default editor at the given filename and linenumber.
59 """Open the default editor at the given filename and linenumber.
60
60
61 This is IPython's default editor hook, you can use it as an example to
61 This is IPython's default editor hook, you can use it as an example to
62 write your own modified one. To set your own editor function as the
62 write your own modified one. To set your own editor function as the
63 new editor hook, call ip.set_hook('editor',yourfunc)."""
63 new editor hook, call ip.set_hook('editor',yourfunc)."""
64
64
65 # IPython configures a default editor at startup by reading $EDITOR from
65 # IPython configures a default editor at startup by reading $EDITOR from
66 # the environment, and falling back on vi (unix) or notepad (win32).
66 # the environment, and falling back on vi (unix) or notepad (win32).
67 editor = self.editor
67 editor = self.editor
68
68
69 # marker for at which line to open the file (for existing objects)
69 # marker for at which line to open the file (for existing objects)
70 if linenum is None or editor=='notepad':
70 if linenum is None or editor=='notepad':
71 linemark = ''
71 linemark = ''
72 else:
72 else:
73 linemark = '+%d' % int(linenum)
73 linemark = '+%d' % int(linenum)
74
74
75 # Enclose in quotes if necessary and legal
75 # Enclose in quotes if necessary and legal
76 if ' ' in editor and os.path.isfile(editor) and editor[0] != '"':
76 if ' ' in editor and os.path.isfile(editor) and editor[0] != '"':
77 editor = '"%s"' % editor
77 editor = '"%s"' % editor
78
78
79 # Call the actual editor
79 # Call the actual editor
80 proc = subprocess.Popen('%s %s %s' % (editor, linemark, filename),
80 proc = subprocess.Popen('%s %s %s' % (editor, linemark, filename),
81 shell=True)
81 shell=True)
82 if wait and proc.wait() != 0:
82 if wait and proc.wait() != 0:
83 raise TryNext()
83 raise TryNext()
84
84
85 import tempfile
85 import tempfile
86 from IPython.utils.decorators import undoc
86 from IPython.utils.decorators import undoc
87
87
88 @undoc
88 @undoc
89 def fix_error_editor(self,filename,linenum,column,msg):
89 def fix_error_editor(self,filename,linenum,column,msg):
90 """DEPRECATED
90 """DEPRECATED
91
91
92 Open the editor at the given filename, linenumber, column and
92 Open the editor at the given filename, linenumber, column and
93 show an error message. This is used for correcting syntax errors.
93 show an error message. This is used for correcting syntax errors.
94 The current implementation only has special support for the VIM editor,
94 The current implementation only has special support for the VIM editor,
95 and falls back on the 'editor' hook if VIM is not used.
95 and falls back on the 'editor' hook if VIM is not used.
96
96
97 Call ip.set_hook('fix_error_editor',yourfunc) to use your own function,
97 Call ip.set_hook('fix_error_editor',yourfunc) to use your own function,
98 """
98 """
99
99
100 warnings.warn("""
100 warnings.warn("""
101 `fix_error_editor` is deprecated as of IPython 6.0 and will be removed
101 `fix_error_editor` is deprecated as of IPython 6.0 and will be removed
102 in future versions. It appears to be used only for automatically fixing syntax
102 in future versions. It appears to be used only for automatically fixing syntax
103 error that has been broken for a few years and has thus been removed. If you
103 error that has been broken for a few years and has thus been removed. If you
104 happend to use this function and still need it please make your voice heard on
104 happend to use this function and still need it please make your voice heard on
105 the mailing list ipython-dev@scipy.org , or on the GitHub Issue tracker:
105 the mailing list ipython-dev@python.org , or on the GitHub Issue tracker:
106 https://github.com/ipython/ipython/issues/9649 """, UserWarning)
106 https://github.com/ipython/ipython/issues/9649 """, UserWarning)
107
107
108 def vim_quickfix_file():
108 def vim_quickfix_file():
109 t = tempfile.NamedTemporaryFile()
109 t = tempfile.NamedTemporaryFile()
110 t.write('%s:%d:%d:%s\n' % (filename,linenum,column,msg))
110 t.write('%s:%d:%d:%s\n' % (filename,linenum,column,msg))
111 t.flush()
111 t.flush()
112 return t
112 return t
113 if os.path.basename(self.editor) != 'vim':
113 if os.path.basename(self.editor) != 'vim':
114 self.hooks.editor(filename,linenum)
114 self.hooks.editor(filename,linenum)
115 return
115 return
116 t = vim_quickfix_file()
116 t = vim_quickfix_file()
117 try:
117 try:
118 if os.system('vim --cmd "set errorformat=%f:%l:%c:%m" -q ' + t.name):
118 if os.system('vim --cmd "set errorformat=%f:%l:%c:%m" -q ' + t.name):
119 raise TryNext()
119 raise TryNext()
120 finally:
120 finally:
121 t.close()
121 t.close()
122
122
123
123
124 def synchronize_with_editor(self, filename, linenum, column):
124 def synchronize_with_editor(self, filename, linenum, column):
125 pass
125 pass
126
126
127
127
128 class CommandChainDispatcher:
128 class CommandChainDispatcher:
129 """ Dispatch calls to a chain of commands until some func can handle it
129 """ Dispatch calls to a chain of commands until some func can handle it
130
130
131 Usage: instantiate, execute "add" to add commands (with optional
131 Usage: instantiate, execute "add" to add commands (with optional
132 priority), execute normally via f() calling mechanism.
132 priority), execute normally via f() calling mechanism.
133
133
134 """
134 """
135 def __init__(self,commands=None):
135 def __init__(self,commands=None):
136 if commands is None:
136 if commands is None:
137 self.chain = []
137 self.chain = []
138 else:
138 else:
139 self.chain = commands
139 self.chain = commands
140
140
141
141
142 def __call__(self,*args, **kw):
142 def __call__(self,*args, **kw):
143 """ Command chain is called just like normal func.
143 """ Command chain is called just like normal func.
144
144
145 This will call all funcs in chain with the same args as were given to
145 This will call all funcs in chain with the same args as were given to
146 this function, and return the result of first func that didn't raise
146 this function, and return the result of first func that didn't raise
147 TryNext"""
147 TryNext"""
148 last_exc = TryNext()
148 last_exc = TryNext()
149 for prio,cmd in self.chain:
149 for prio,cmd in self.chain:
150 #print "prio",prio,"cmd",cmd #dbg
150 #print "prio",prio,"cmd",cmd #dbg
151 try:
151 try:
152 return cmd(*args, **kw)
152 return cmd(*args, **kw)
153 except TryNext as exc:
153 except TryNext as exc:
154 last_exc = exc
154 last_exc = exc
155 # if no function will accept it, raise TryNext up to the caller
155 # if no function will accept it, raise TryNext up to the caller
156 raise last_exc
156 raise last_exc
157
157
158 def __str__(self):
158 def __str__(self):
159 return str(self.chain)
159 return str(self.chain)
160
160
161 def add(self, func, priority=0):
161 def add(self, func, priority=0):
162 """ Add a func to the cmd chain with given priority """
162 """ Add a func to the cmd chain with given priority """
163 self.chain.append((priority, func))
163 self.chain.append((priority, func))
164 self.chain.sort(key=lambda x: x[0])
164 self.chain.sort(key=lambda x: x[0])
165
165
166 def __iter__(self):
166 def __iter__(self):
167 """ Return all objects in chain.
167 """ Return all objects in chain.
168
168
169 Handy if the objects are not callable.
169 Handy if the objects are not callable.
170 """
170 """
171 return iter(self.chain)
171 return iter(self.chain)
172
172
173
173
174 def shutdown_hook(self):
174 def shutdown_hook(self):
175 """ default shutdown hook
175 """ default shutdown hook
176
176
177 Typically, shotdown hooks should raise TryNext so all shutdown ops are done
177 Typically, shotdown hooks should raise TryNext so all shutdown ops are done
178 """
178 """
179
179
180 #print "default shutdown hook ok" # dbg
180 #print "default shutdown hook ok" # dbg
181 return
181 return
182
182
183
183
184 def late_startup_hook(self):
184 def late_startup_hook(self):
185 """ Executed after ipython has been constructed and configured
185 """ Executed after ipython has been constructed and configured
186
186
187 """
187 """
188 #print "default startup hook ok" # dbg
188 #print "default startup hook ok" # dbg
189
189
190
190
191 def show_in_pager(self, data, start, screen_lines):
191 def show_in_pager(self, data, start, screen_lines):
192 """ Run a string through pager """
192 """ Run a string through pager """
193 # raising TryNext here will use the default paging functionality
193 # raising TryNext here will use the default paging functionality
194 raise TryNext
194 raise TryNext
195
195
196
196
197 def pre_prompt_hook(self):
197 def pre_prompt_hook(self):
198 """ Run before displaying the next prompt
198 """ Run before displaying the next prompt
199
199
200 Use this e.g. to display output from asynchronous operations (in order
200 Use this e.g. to display output from asynchronous operations (in order
201 to not mess up text entry)
201 to not mess up text entry)
202 """
202 """
203
203
204 return None
204 return None
205
205
206
206
207 def pre_run_code_hook(self):
207 def pre_run_code_hook(self):
208 """ Executed before running the (prefiltered) code in IPython """
208 """ Executed before running the (prefiltered) code in IPython """
209 return None
209 return None
210
210
211
211
212 def clipboard_get(self):
212 def clipboard_get(self):
213 """ Get text from the clipboard.
213 """ Get text from the clipboard.
214 """
214 """
215 from IPython.lib.clipboard import (
215 from IPython.lib.clipboard import (
216 osx_clipboard_get, tkinter_clipboard_get,
216 osx_clipboard_get, tkinter_clipboard_get,
217 win32_clipboard_get
217 win32_clipboard_get
218 )
218 )
219 if sys.platform == 'win32':
219 if sys.platform == 'win32':
220 chain = [win32_clipboard_get, tkinter_clipboard_get]
220 chain = [win32_clipboard_get, tkinter_clipboard_get]
221 elif sys.platform == 'darwin':
221 elif sys.platform == 'darwin':
222 chain = [osx_clipboard_get, tkinter_clipboard_get]
222 chain = [osx_clipboard_get, tkinter_clipboard_get]
223 else:
223 else:
224 chain = [tkinter_clipboard_get]
224 chain = [tkinter_clipboard_get]
225 dispatcher = CommandChainDispatcher()
225 dispatcher = CommandChainDispatcher()
226 for func in chain:
226 for func in chain:
227 dispatcher.add(func)
227 dispatcher.add(func)
228 text = dispatcher()
228 text = dispatcher()
229 return text
229 return text
@@ -1,118 +1,118 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Release data for the IPython project."""
2 """Release data for the IPython project."""
3
3
4 #-----------------------------------------------------------------------------
4 #-----------------------------------------------------------------------------
5 # Copyright (c) 2008, IPython Development Team.
5 # Copyright (c) 2008, IPython Development Team.
6 # Copyright (c) 2001, Fernando Perez <fernando.perez@colorado.edu>
6 # Copyright (c) 2001, Fernando Perez <fernando.perez@colorado.edu>
7 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
7 # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
8 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
8 # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
9 #
9 #
10 # Distributed under the terms of the Modified BSD License.
10 # Distributed under the terms of the Modified BSD License.
11 #
11 #
12 # The full license is in the file COPYING.txt, distributed with this software.
12 # The full license is in the file COPYING.txt, distributed with this software.
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 # Name of the package for release purposes. This is the name which labels
15 # Name of the package for release purposes. This is the name which labels
16 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
16 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
17 name = 'ipython'
17 name = 'ipython'
18
18
19 # IPython version information. An empty _version_extra corresponds to a full
19 # IPython version information. An empty _version_extra corresponds to a full
20 # release. 'dev' as a _version_extra string means this is a development
20 # release. 'dev' as a _version_extra string means this is a development
21 # version
21 # version
22 _version_major = 6
22 _version_major = 6
23 _version_minor = 0
23 _version_minor = 0
24 _version_patch = 0
24 _version_patch = 0
25 _version_extra = '.dev'
25 _version_extra = '.dev'
26 # _version_extra = 'rc1'
26 # _version_extra = 'rc1'
27 # _version_extra = '' # Uncomment this for full releases
27 # _version_extra = '' # Uncomment this for full releases
28
28
29 # Construct full version string from these.
29 # Construct full version string from these.
30 _ver = [_version_major, _version_minor, _version_patch]
30 _ver = [_version_major, _version_minor, _version_patch]
31
31
32 __version__ = '.'.join(map(str, _ver))
32 __version__ = '.'.join(map(str, _ver))
33 if _version_extra:
33 if _version_extra:
34 __version__ = __version__ + _version_extra
34 __version__ = __version__ + _version_extra
35
35
36 version = __version__ # backwards compatibility name
36 version = __version__ # backwards compatibility name
37 version_info = (_version_major, _version_minor, _version_patch, _version_extra)
37 version_info = (_version_major, _version_minor, _version_patch, _version_extra)
38
38
39 # Change this when incrementing the kernel protocol version
39 # Change this when incrementing the kernel protocol version
40 kernel_protocol_version_info = (5, 0)
40 kernel_protocol_version_info = (5, 0)
41 kernel_protocol_version = "%i.%i" % kernel_protocol_version_info
41 kernel_protocol_version = "%i.%i" % kernel_protocol_version_info
42
42
43 description = "IPython: Productive Interactive Computing"
43 description = "IPython: Productive Interactive Computing"
44
44
45 long_description = \
45 long_description = \
46 """
46 """
47 IPython provides a rich toolkit to help you make the most out of using Python
47 IPython provides a rich toolkit to help you make the most out of using Python
48 interactively. Its main components are:
48 interactively. Its main components are:
49
49
50 * A powerful interactive Python shell
50 * A powerful interactive Python shell
51 * A `Jupyter <http://jupyter.org/>`_ kernel to work with Python code in Jupyter
51 * A `Jupyter <http://jupyter.org/>`_ kernel to work with Python code in Jupyter
52 notebooks and other interactive frontends.
52 notebooks and other interactive frontends.
53
53
54 The enhanced interactive Python shells have the following main features:
54 The enhanced interactive Python shells have the following main features:
55
55
56 * Comprehensive object introspection.
56 * Comprehensive object introspection.
57
57
58 * Input history, persistent across sessions.
58 * Input history, persistent across sessions.
59
59
60 * Caching of output results during a session with automatically generated
60 * Caching of output results during a session with automatically generated
61 references.
61 references.
62
62
63 * Extensible tab completion, with support by default for completion of python
63 * Extensible tab completion, with support by default for completion of python
64 variables and keywords, filenames and function keywords.
64 variables and keywords, filenames and function keywords.
65
65
66 * Extensible system of 'magic' commands for controlling the environment and
66 * Extensible system of 'magic' commands for controlling the environment and
67 performing many tasks related either to IPython or the operating system.
67 performing many tasks related either to IPython or the operating system.
68
68
69 * A rich configuration system with easy switching between different setups
69 * A rich configuration system with easy switching between different setups
70 (simpler than changing $PYTHONSTARTUP environment variables every time).
70 (simpler than changing $PYTHONSTARTUP environment variables every time).
71
71
72 * Session logging and reloading.
72 * Session logging and reloading.
73
73
74 * Extensible syntax processing for special purpose situations.
74 * Extensible syntax processing for special purpose situations.
75
75
76 * Access to the system shell with user-extensible alias system.
76 * Access to the system shell with user-extensible alias system.
77
77
78 * Easily embeddable in other Python programs and GUIs.
78 * Easily embeddable in other Python programs and GUIs.
79
79
80 * Integrated access to the pdb debugger and the Python profiler.
80 * Integrated access to the pdb debugger and the Python profiler.
81
81
82 The latest development version is always available from IPython's `GitHub
82 The latest development version is always available from IPython's `GitHub
83 site <http://github.com/ipython>`_.
83 site <http://github.com/ipython>`_.
84 """
84 """
85
85
86 license = 'BSD'
86 license = 'BSD'
87
87
88 authors = {'Fernando' : ('Fernando Perez','fperez.net@gmail.com'),
88 authors = {'Fernando' : ('Fernando Perez','fperez.net@gmail.com'),
89 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
89 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
90 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'),
90 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'),
91 'Ville' : ('Ville Vainio','vivainio@gmail.com'),
91 'Ville' : ('Ville Vainio','vivainio@gmail.com'),
92 'Brian' : ('Brian E Granger', 'ellisonbg@gmail.com'),
92 'Brian' : ('Brian E Granger', 'ellisonbg@gmail.com'),
93 'Min' : ('Min Ragan-Kelley', 'benjaminrk@gmail.com'),
93 'Min' : ('Min Ragan-Kelley', 'benjaminrk@gmail.com'),
94 'Thomas' : ('Thomas A. Kluyver', 'takowl@gmail.com'),
94 'Thomas' : ('Thomas A. Kluyver', 'takowl@gmail.com'),
95 'Jorgen' : ('Jorgen Stenarson', 'jorgen.stenarson@bostream.nu'),
95 'Jorgen' : ('Jorgen Stenarson', 'jorgen.stenarson@bostream.nu'),
96 'Matthias' : ('Matthias Bussonnier', 'bussonniermatthias@gmail.com'),
96 'Matthias' : ('Matthias Bussonnier', 'bussonniermatthias@gmail.com'),
97 }
97 }
98
98
99 author = 'The IPython Development Team'
99 author = 'The IPython Development Team'
100
100
101 author_email = 'ipython-dev@scipy.org'
101 author_email = 'ipython-dev@python.org'
102
102
103 url = 'http://ipython.org'
103 url = 'https://ipython.org'
104
104
105
105
106 platforms = ['Linux','Mac OSX','Windows']
106 platforms = ['Linux','Mac OSX','Windows']
107
107
108 keywords = ['Interactive','Interpreter','Shell', 'Embedding']
108 keywords = ['Interactive','Interpreter','Shell', 'Embedding']
109
109
110 classifiers = [
110 classifiers = [
111 'Framework :: IPython',
111 'Framework :: IPython',
112 'Intended Audience :: Developers',
112 'Intended Audience :: Developers',
113 'Intended Audience :: Science/Research',
113 'Intended Audience :: Science/Research',
114 'License :: OSI Approved :: BSD License',
114 'License :: OSI Approved :: BSD License',
115 'Programming Language :: Python',
115 'Programming Language :: Python',
116 'Programming Language :: Python :: 3',
116 'Programming Language :: Python :: 3',
117 'Topic :: System :: Shells'
117 'Topic :: System :: Shells'
118 ]
118 ]
General Comments 0
You need to be logged in to leave comments. Login now