##// END OF EJS Templates
ipapi.py => core/ipapi.py and imports updated.
Brian Granger -
Show More
@@ -1,9 +1,9 b''
1 1 # -*- coding: utf-8 -*-
2 2 """ IPython extension: add %clear magic """
3 3
4 import IPython.ipapi
4 from IPython.core import ipapi
5 5 import gc
6 ip = IPython.ipapi.get()
6 ip = ipapi.get()
7 7
8 8 def clear_f(self,arg):
9 9 """ Clear various data (e.g. stored history data)
@@ -2,8 +2,8 b''
2 2 """ %env magic command for storing environment variables persistently
3 3 """
4 4
5 import IPython.ipapi
6 ip = IPython.ipapi.get()
5 from IPython.core import ipapi
6 ip = ipapi.get()
7 7
8 8 import os,sys
9 9
@@ -16,7 +16,7 b' def restore_env(self):'
16 16 os.environ[k] = os.environ.get(k,"") + v
17 17 for k,v in env['pre']:
18 18 os.environ[k] = v + os.environ.get(k,"")
19 raise IPython.ipapi.TryNext
19 raise ipapi.TryNext
20 20
21 21 ip.set_hook('late_startup_hook', restore_env)
22 22
@@ -8,10 +8,10 b' var = %magic blah blah'
8 8 var = !ls
9 9 """
10 10
11 import IPython.ipapi
11 from IPython.core import ipapi
12 12 from IPython.utils.genutils import *
13 13
14 ip = IPython.ipapi.get()
14 ip = ipapi.get()
15 15
16 16 import re
17 17
@@ -58,6 +58,6 b' def regex_prefilter_f(self,line):'
58 58 if mo:
59 59 return handler(line,mo)
60 60
61 raise IPython.ipapi.TryNext
61 raise ipapi.TryNext
62 62
63 63 ip.set_hook('input_prefilter', regex_prefilter_f)
@@ -2,7 +2,7 b''
2 2
3 3 import curses, fcntl, signal, struct, tty, textwrap, inspect
4 4
5 from IPython import ipapi
5 from IPython.coreZ import ipapi
6 6
7 7 import astyle, ipipe
8 8
@@ -1,7 +1,7 b''
1 1 # -*- coding: iso-8859-1 -*-
2 2
3 3 import ipipe, os, webbrowser, urllib
4 from IPython import ipapi
4 from IPython.core import ipapi
5 5 import wx
6 6 import wx.grid, wx.html
7 7
@@ -139,7 +139,7 b' except ImportError:'
139 139 genutils = None
140 140 generics = None
141 141
142 from IPython import ipapi
142 from IPython.core import ipapi
143 143
144 144
145 145 __all__ = [
@@ -5,9 +5,9 b' IPython extension that installs the completers related to external apps.'
5 5 The actual implementations are in Extensions/ipy_completers.py
6 6
7 7 """
8 import IPython.ipapi
8 from IPython.core import ipapi
9 9
10 ip = IPython.ipapi.get()
10 ip = ipapi.get()
11 11
12 12 from ipy_completers import *
13 13
@@ -224,15 +224,15 b' reloader = ModuleReloader()'
224 224 #------------------------------------------------------------------------------
225 225 # IPython connectivity
226 226 #------------------------------------------------------------------------------
227 import IPython.ipapi
227 from IPython.core import ipapi
228 228
229 ip = IPython.ipapi.get()
229 ip = ipapi.get()
230 230
231 231 autoreload_enabled = False
232 232
233 233 def runcode_hook(self):
234 234 if not autoreload_enabled:
235 raise IPython.ipapi.TryNext
235 raise ipapi.TryNext
236 236 try:
237 237 reloader.check()
238 238 except:
@@ -7,12 +7,12 b' but the basic idea is to do:'
7 7 ip.set_hook('complete_command', svn_completer, str_key = 'svn')
8 8
9 9 """
10 import IPython.ipapi
10 import IPython.core import ipapi
11 11 import glob,os,shlex,sys
12 12 import inspect
13 13 from time import time
14 14 from zipimport import zipimporter
15 ip = IPython.ipapi.get()
15 ip = ipapi.get()
16 16
17 17 try:
18 18 set
@@ -329,7 +329,7 b' def cd_completer(self, event):'
329 329 if ' ' in d:
330 330 # we don't want to deal with any of that, complex code
331 331 # for this is elsewhere
332 raise IPython.ipapi.TryNext
332 raise ipapi.TryNext
333 333 found.append( d )
334 334
335 335 if not found:
@@ -341,7 +341,7 b' def cd_completer(self, event):'
341 341 if bkmatches:
342 342 return bkmatches
343 343
344 raise IPython.ipapi.TryNext
344 raise ipapi.TryNext
345 345
346 346
347 347 def single_dir_expand(matches):
@@ -13,8 +13,8 b' ipy_profile_PROFILENAME etc.'
13 13 """
14 14
15 15 import IPython.rlineimpl as readline
16 import IPython.ipapi
17 ip = IPython.ipapi.get()
16 from IPython.core import ipapi
17 ip = ipapi.get()
18 18
19 19 o = ip.options
20 20
@@ -5,8 +5,8 b' They should honor the line number argument, at least.'
5 5 Contributions are *very* welcome.
6 6 """
7 7
8 import IPython.ipapi
9 ip = IPython.ipapi.get()
8 from IPython.core import ipapi
9 ip = ipapi.get()
10 10
11 11 from IPython.Itpl import itplns
12 12 import os
@@ -29,7 +29,7 b' def install_editor(run_template, wait = False):'
29 29 cmd = itplns(run_template, locals())
30 30 print ">",cmd
31 31 if os.system(cmd) != 0:
32 raise IPython.ipapi.TryNext()
32 raise ipapi.TryNext()
33 33 if wait:
34 34 raw_input("Press Enter when done editing:")
35 35
@@ -1,11 +1,11 b''
1 import IPython.ipapi
2 ip = IPython.ipapi.get()
1 from IPython.core import ipapi
2 ip = ipapi.get()
3 3
4 4 import os,pprint
5 5
6 6 def export(filename = None):
7 7
8 lines = ['import IPython.ipapi', 'ip = IPython.ipapi.get()','']
8 lines = ['import IPython.core.ipapi', 'ip = IPython.core.ipapi.get()','']
9 9
10 10 vars = ip.db.keys('autorestore/*')
11 11 vars.sort()
@@ -7,8 +7,8 b' to.'
7 7 # for the purposes of this module, every module that has the name 'ip' globally
8 8 # installed as below is an IPython extension
9 9
10 import IPython.ipapi
11 ip = IPython.ipapi.get()
10 from IPython.core import ipapi
11 ip = ipapi.get()
12 12
13 13 import sys,textwrap,inspect
14 14
@@ -34,7 +34,7 b' class ExtUtil:'
34 34 act = []
35 35 for mname,m in sys.modules.items():
36 36 o = getattr(m, 'ip', None)
37 if isinstance(o, IPython.ipapi.IPApi):
37 if isinstance(o, ipapi.IPApi):
38 38 act.append((mname,m))
39 39 act.sort()
40 40 return act
@@ -15,13 +15,13 b" do some useful tricks on their own, though (like use 'mglob' patterns)."
15 15 Not to be confused with ipipe commands (ils etc.) that also start with i.
16 16 """
17 17
18 import IPython.ipapi
19 ip = IPython.ipapi.get()
18 from IPython.core import ipapi
19 ip = ipapi.get()
20 20
21 21 import shutil,os,shlex
22 22 from IPython.external import mglob
23 23 from IPython.external.path import path
24 from IPython.ipapi import UsageError
24 from IPython.core.ipapi import UsageError
25 25 import IPython.utils.generics
26 26
27 27 def parse_args(args):
@@ -229,7 +229,7 b' def complete_pathobj(obj, prev_completions):'
229 229 if res:
230 230 return res
231 231 # just return normal attributes of 'path' object if the dir is empty
232 raise IPython.ipapi.TryNext
232 raise ipapi.TryNext
233 233
234 234 complete_pathobj = IPython.utils.generics.complete_object.when_type(PathObj)(complete_pathobj)
235 235
@@ -8,8 +8,8 b' http://www.gnu.org/software/global/'
8 8
9 9 """
10 10
11 import IPython.ipapi
12 ip = IPython.ipapi.get()
11 from IPython.core import ipapi
12 ip = ipapi.get()
13 13 import os
14 14
15 15 # alter to your liking
@@ -9,7 +9,7 b' only whitespace as completer delimiter. If this works well, we will'
9 9 do the same in default completer.
10 10
11 11 """
12 from IPython import ipapi
12 from IPython.core import ipapi
13 13 from IPython.utils import generics
14 14 from IPython.utils.genutils import dir2
15 15
@@ -8,8 +8,8 b' Stores variables in Struct with some notes in PicleShare database'
8 8 """
9 9
10 10 from datetime import datetime
11 import IPython.ipapi
12 ip = IPython.ipapi.get()
11 from IPython.core import ipapi
12 ip = ipapi.get()
13 13
14 14 import pickleshare
15 15
@@ -9,8 +9,8 b' Stuff that is considered obsolete / redundant is gradually moved here.'
9 9
10 10 """
11 11
12 import IPython.ipapi
13 ip = IPython.ipapi.get()
12 from IPython.core import ipapi
13 ip = ipapi.get()
14 14
15 15 import os,sys
16 16
@@ -201,8 +201,8 b' def _lookfor_generate_cache(module, import_modules, regenerate):'
201 201 # IPython connectivity
202 202 #------------------------------------------------------------------------------
203 203
204 import IPython.ipapi
205 ip = IPython.ipapi.get()
204 from IPython.core import ipapi
205 ip = ipapi.get()
206 206
207 207 _lookfor_modules = ['numpy', 'scipy']
208 208
@@ -3,8 +3,8 b''
3 3 Add %p4 magic for pythonic p4 (Perforce) usage.
4 4 """
5 5
6 import IPython.ipapi
7 ip = IPython.ipapi.get()
6 from IPython.core import ipapi
7 ip = ipapi.get()
8 8
9 9 import os,sys,marshal
10 10
@@ -16,12 +16,12 b' for numpy dtype objects, add the following to your ipy_user_conf.py::'
16 16 ipy_pretty.for_type_by_name('numpy', 'dtype', ipy_pretty.dtype_pprinter)
17 17 """
18 18
19 import IPython.ipapi
19 from IPython.core import ipapi
20 20 from IPython.utils.genutils import Term
21 21
22 22 from IPython.external import pretty
23 23
24 ip = IPython.ipapi.get()
24 ip = ipapi.get()
25 25
26 26
27 27 #### Implementation ############################################################
@@ -14,7 +14,7 b' similar as possible to the default Python ones, for inclusion in doctests."""'
14 14 # get various stuff that are there for historical / familiarity reasons
15 15 import ipy_legacy
16 16
17 from IPython import ipapi
17 from IPython.core import ipapi
18 18
19 19 from IPython.Extensions import InterpreterPasteInput
20 20
@@ -5,11 +5,11 b' This profile loads the math/cmath modules as well as all of numpy.'
5 5 It exposes numpy via the 'np' shorthand as well for convenience.
6 6 """
7 7
8 import IPython.ipapi
8 from IPython.core import ipapi
9 9 import ipy_defaults
10 10
11 11 def main():
12 ip = IPython.ipapi.get()
12 ip = ipapi.get()
13 13
14 14 try:
15 15 ip.ex("import math,cmath")
@@ -6,11 +6,11 b" It exposes numpy and scipy via the 'np' and 'sp' shorthands as well for"
6 6 convenience.
7 7 """
8 8
9 import IPython.ipapi
9 from IPython.core import ipapi
10 10 import ipy_defaults
11 11
12 12 def main():
13 ip = IPython.ipapi.get()
13 ip = ipapi.get()
14 14
15 15 try:
16 16 ip.ex("import math,cmath")
@@ -7,7 +7,7 b" shell mode and is recommended for users who don't care about pysh-mode"
7 7 compatibility)
8 8 """
9 9
10 from IPython import ipapi
10 from IPython.core import ipapi
11 11 import os,re,textwrap
12 12
13 13 # The import below effectively obsoletes your old-style ipythonrc[.ini],
@@ -17,7 +17,7 b' Authors'
17 17 # Distributed under the terms of the BSD License. The full license is in
18 18 # the file COPYING, distributed as part of this software.
19 19
20 from IPython import ipapi
20 from IPython.core import ipapi
21 21 from IPython import Release
22 22 from types import StringType
23 23 import sys
@@ -1,7 +1,7 b''
1 1 import inspect
2 import IPython.ipapi
2 from IPython.core import ipapi
3 3 from IPython.utils.genutils import arg_split
4 ip = IPython.ipapi.get()
4 ip = ipapi.get()
5 5
6 6 from IPython.core import debugger
7 7
@@ -15,8 +15,8 b' extensions are allowed to do that).'
15 15
16 16 """
17 17
18 import IPython.ipapi
19 ip = IPython.ipapi.get()
18 from IPython.core import ipapi
19 ip = ipapi.get()
20 20
21 21
22 22 import os,re,fnmatch,sys
@@ -2,9 +2,9 b''
2 2
3 3 """ IPython extension: Render templates from variables and paste to clipbard """
4 4
5 import IPython.ipapi
5 from IPython.core import ipapi
6 6
7 ip = IPython.ipapi.get()
7 ip = ipapi.get()
8 8
9 9 from string import Template
10 10 import sys,os
@@ -13,8 +13,8 b' This is a bit like \'M-x server-start" or gnuserv in the emacs world.'
13 13
14 14 """
15 15
16 import IPython.ipapi
17 ip = IPython.ipapi.get()
16 from IPython.core import ipapi
17 ip = ipapi.get()
18 18
19 19 import SocketServer
20 20
@@ -10,10 +10,10 b' If _ip.options.verbose is true, show exit status if nonzero'
10 10 """
11 11
12 12 import signal,os,sys
13 import IPython.ipapi
13 from IPython.core import ipapi
14 14 import subprocess
15 15
16 ip = IPython.ipapi.get()
16 ip = ipapi.get()
17 17
18 18 def new_ipsystem_posix(cmd):
19 19 """ ctrl+c ignoring replacement for system() command in iplib.
@@ -5,9 +5,9 b' IPython extension that installs completers related to core ipython behaviour.'
5 5 The actual implementations are in Extensions/ipy_completers.py
6 6
7 7 """
8 import IPython.ipapi
8 from IPython.core import ipapi
9 9
10 ip = IPython.ipapi.get()
10 ip = ipapi.get()
11 11
12 12 from ipy_completers import *
13 13
@@ -1,5 +1,5 b''
1 import IPython.ipapi
2 ip = IPython.ipapi.get()
1 from IPython.core import ipapi
2 ip = ipapi.get()
3 3
4 4 import win32api
5 5 import win32ui
@@ -7,8 +7,8 b' should reside there.'
7 7
8 8 """
9 9
10 import IPython.ipapi
11 ip = IPython.ipapi.get()
10 from IPython.core import ipapi
11 ip = ipapi.get()
12 12
13 13 # add system wide configuration information, import extensions etc. here.
14 14 # nothing here is essential
@@ -52,7 +52,7 b' Notes'
52 52 from enthought.traits import api as T
53 53
54 54 # IPython imports
55 from IPython.ipapi import TryNext, get as ipget
55 from IPython.core.ipapi import TryNext, get as ipget
56 56 from IPython.utils.genutils import dir2
57 57 try:
58 58 set
@@ -67,15 +67,15 b' something. Instead of edit, use the vim magic. Thats it!'
67 67
68 68 """
69 69
70 import IPython.ipapi
71 #import ipythonhooks
70 from IPython.core import ipapi
71
72 72 import socket, select
73 73 import os, threading, subprocess
74 74 import re
75 75
76 76 ERRCONDS = select.POLLHUP|select.POLLERR
77 77 SERVER = None
78 ip = IPython.ipapi.get()
78 ip = ipapi.get()
79 79
80 80 # this listens to a unix domain socket in a separate thread, so that comms
81 81 # between a vim instance and ipython can happen in a fun and productive way
@@ -161,7 +161,7 b' def shutdown_server(self):'
161 161 if SERVER:
162 162 SERVER.stop()
163 163 SERVER.join(3)
164 raise IPython.ipapi.TryNext
164 raise ipapi.TryNext
165 165
166 166 ip.set_hook('shutdown_hook', shutdown_server, 10)
167 167
@@ -4,8 +4,8 b' r""" %which magic command'
4 4
5 5 """
6 6
7 import IPython.ipapi
8 ip = IPython.ipapi.get()
7 from IPython.core import ipapi
8 ip = ipapi.get()
9 9
10 10 import os,sys
11 11 from fnmatch import fnmatch
@@ -21,10 +21,10 b' For more details: https://bugs.launchpad.net/ipython/+bug/249036'
21 21
22 22 import os
23 23
24 import IPython.ipapi
24 from IPython.core import ipapi
25 25 import rpdb2
26 26
27 ip = IPython.ipapi.get()
27 ip = ipapi.get()
28 28
29 29 rpdb_started = False
30 30
@@ -58,7 +58,7 b' def wdb_f(self, arg):'
58 58
59 59 path = os.path.abspath(arg)
60 60 if not os.path.isfile(path):
61 raise IPython.ipapi.UsageError("%%wdb: file %s does not exist" % path)
61 raise ipapi.UsageError("%%wdb: file %s does not exist" % path)
62 62 if not rpdb_started:
63 63 passwd = ip.db.get('winpdb_pass', None)
64 64 if passwd is None:
@@ -1,7 +1,7 b''
1 1 #!/usr/bin/env python
2 2
3 import IPython.ipapi
4 ip = IPython.ipapi.get()
3 from IPython.core import ipapi
4 ip = ipapi.get()
5 5
6 6 import os, subprocess
7 7
@@ -47,7 +47,7 b' import threading,Queue'
47 47
48 48 from IPython.utils import genutils
49 49
50 import IPython.ipapi
50 from IPython.core import ipapi
51 51
52 52 if os.name == 'nt':
53 53 def kill_process(pid):
@@ -128,7 +128,7 b' def jobctrl_prefilter_f(self,line):'
128 128 return '_ip.startjob(%s)' % genutils.make_quoted_expr(line)
129 129 return '_ip.jobq(%s)' % genutils.make_quoted_expr(line)
130 130
131 raise IPython.ipapi.TryNext
131 raise ipapi.TryNext
132 132
133 133 def jobq_output_hook(self):
134 134 if not _jobq:
@@ -230,7 +230,7 b' def jobctrl_shellcmd(ip,cmd):'
230 230
231 231 def install():
232 232 global ip
233 ip = IPython.ipapi.get()
233 ip = ipapi.get()
234 234 # needed to make startjob visible as _ip.startjob('blah')
235 235 ip.startjob = startjob
236 236 ip.set_hook('input_prefilter', jobctrl_prefilter_f)
@@ -43,9 +43,9 b' l.__class__ l.__hash__ l.__repr__ l.expandtabs l.lj'
43 43 ... (completions for string variable shown ) ...
44 44
45 45 """
46 import IPython.ipapi
46 from IPython.core import ipapi
47 47 import pprint
48 ip = IPython.ipapi.get()
48 ip = ipapi.get()
49 49
50 50 curdata = []
51 51
@@ -5,9 +5,9 b''
5 5 Stores variables, aliases etc. in PickleShare database.
6 6 """
7 7
8 import IPython.ipapi
9 from IPython.ipapi import UsageError
10 ip = IPython.ipapi.get()
8 from IPython.core import ipapi
9 from IPython.core.ipapi import UsageError
10 ip = ipapi.get()
11 11
12 12 import pickleshare
13 13
@@ -47,7 +47,7 b' def restore_data(self):'
47 47 refresh_variables(ip)
48 48 restore_aliases(self)
49 49 restore_dhist(self)
50 raise IPython.ipapi.TryNext
50 raise ipapi.TryNext
51 51
52 52 ip.set_hook('late_startup_hook', restore_data)
53 53
@@ -1,6 +1,6 b''
1 import IPython.ipapi
1 from IPython.core import ipapi
2 2
3 ip = IPython.ipapi.get()
3 ip = ipapi.get()
4 4
5 5 def clip_f( self, parameter_s = '' ):
6 6 """Save a set of lines to the clipboard.
@@ -53,8 +53,8 b' from IPython.macro import Macro'
53 53 from IPython.utils.genutils import *
54 54 from IPython import platutils
55 55 import IPython.utils.generics
56 import IPython.ipapi
57 from IPython.ipapi import UsageError
56 from IPython.core import ipapi
57 from IPython.core.ipapi import UsageError
58 58 from IPython.testing import decorators as testdec
59 59
60 60 #***************************************************************************
@@ -720,7 +720,7 b' Currently the magic system has the following functions:\\n"""'
720 720 try:
721 721 IPython.utils.generics.inspect_object(info.obj)
722 722 return
723 except IPython.ipapi.TryNext:
723 except ipapi.TryNext:
724 724 pass
725 725 # Get the docstring of the class property if it exists.
726 726 path = oname.split('.')
@@ -2386,7 +2386,7 b' Currently the magic system has the following functions:\\n"""'
2386 2386 sys.stdout.flush()
2387 2387 try:
2388 2388 self.shell.hooks.editor(filename,lineno)
2389 except IPython.ipapi.TryNext:
2389 except ipapi.TryNext:
2390 2390 warn('Could not open editor')
2391 2391 return
2392 2392
@@ -23,7 +23,7 b' import time'
23 23 from IPython.utils import coloransi
24 24 from IPython import Release
25 25 from IPython.external.Itpl import ItplNS
26 from IPython.ipapi import TryNext
26 from IPython.core.ipapi import TryNext
27 27 from IPython.ipstruct import Struct
28 28 from IPython.macro import Macro
29 29 import IPython.utils.generics
@@ -34,7 +34,8 b' except ImportError:'
34 34
35 35 # IPython imports
36 36 import IPython
37 from IPython import ultraTB, ipapi
37 from IPython import ultraTB
38 from IPython.core import ipapi
38 39 from IPython.Magic import Magic
39 40 from IPython.utils.genutils import Term,warn,error,flag_calls, ask_yes_no
40 41 from IPython.iplib import InteractiveShell
@@ -562,7 +563,7 b' class MatplotlibShellBase:'
562 563 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
563 564
564 565 # Build a user namespace initialized with matplotlib/matlab features.
565 user_ns, user_global_ns = IPython.ipapi.make_user_namespaces(user_ns,
566 user_ns, user_global_ns = ipapi.make_user_namespaces(user_ns,
566 567 user_global_ns)
567 568
568 569 # Import numpy as np/pyplot as plt are conventions we're trying to
@@ -1088,7 +1089,7 b' def _load_pylab(user_ns):'
1088 1089 This little utility must be called AFTER the actual ipython instance is
1089 1090 running, since only then will the options file have been fully parsed."""
1090 1091
1091 ip = IPython.ipapi.get()
1092 ip = ipapi.get()
1092 1093 if ip.options.pylab_import_all:
1093 1094 ip.ex("from matplotlib.pylab import *")
1094 1095 ip.IP.user_config_ns.update(ip.user_ns)
@@ -18,8 +18,8 b' description on what you could do here.'
18 18
19 19 # Most of your config files and extensions will probably start with this import
20 20
21 import IPython.ipapi
22 ip = IPython.ipapi.get()
21 from IPython.core import ipapi
22 ip = ipapi.get()
23 23
24 24 # You probably want to uncomment this if you did %upgrade -nolegacy
25 25 # import ipy_defaults
@@ -73,7 +73,7 b' import sys'
73 73 import IPython.rlineimpl as readline
74 74 import itertools
75 75 from IPython.ipstruct import Struct
76 from IPython import ipapi
76 from IPython.core import ipapi
77 77 from IPython.utils import generics
78 78 import types
79 79
@@ -31,7 +31,8 b' import linecache'
31 31 import os
32 32 import sys
33 33
34 from IPython import PyColorize, ipapi
34 from IPython import PyColorize
35 from IPython.core import ipapi
35 36 from IPython.utils import coloransi
36 37 from IPython.utils.genutils import Term
37 38 from IPython.core.excolors import exception_colors
@@ -6,7 +6,7 b' import fnmatch'
6 6 import os
7 7
8 8 from IPython.utils.genutils import Term, ask_yes_no, warn
9 import IPython.ipapi
9 from IPython.core import ipapi
10 10
11 11 def magic_history(self, parameter_s = ''):
12 12 """Print input history (_i<n> variables), with most recent last.
@@ -228,7 +228,7 b' class ShadowHist:'
228 228 #print "new",newidx # dbg
229 229 self.db.hset('shadowhist',ent, newidx)
230 230 except:
231 IPython.ipapi.get().IP.showtraceback()
231 ipapi.get().IP.showtraceback()
232 232 print "WARNING: disabling shadow history"
233 233 self.disabled = True
234 234
@@ -19,8 +19,8 b" For example, suppose that you have a module called 'myiphooks' in your"
19 19 PYTHONPATH, which contains the following definition:
20 20
21 21 import os
22 import IPython.ipapi
23 ip = IPython.ipapi.get()
22 from IPython.core import ipapi
23 ip = ipapi.get()
24 24
25 25 def calljed(self,filename, linenum):
26 26 "My editor hook calls the jed editor directly."
@@ -41,7 +41,7 b' somewhere in your configuration files or ipython command line.'
41 41 # the file COPYING, distributed as part of this software.
42 42 #*****************************************************************************
43 43
44 from IPython import ipapi
44 from IPython.core import ipapi
45 45
46 46 import os,bisect
47 47 from IPython.utils.genutils import Term,shell
@@ -24,8 +24,8 b' That way the module is imported at startup and you can have all your'
24 24 personal configuration (as opposed to boilerplate ipythonrc-PROFILENAME
25 25 stuff) in there.
26 26
27 import IPython.ipapi
28 ip = IPython.ipapi.get()
27 from IPython.core import ipapi
28 ip = ipapi.get()
29 29
30 30 def ankka_f(self, arg):
31 31 print 'Ankka',self,'says uppercase:',arg.upper()
@@ -331,8 +331,8 b' class IPApi(object):'
331 331 To use this, you first must obtain a handle on the ipython object as
332 332 indicated above, via:
333 333
334 import IPython.ipapi
335 ip = IPython.ipapi.get()
334 from IPython.core import ipapi
335 ip = ipapi.get()
336 336
337 337 Once this is done, inside a routine foo() where you want to expose
338 338 variables x and y, you do the following:
@@ -22,5 +22,8 b' def test_import_history():'
22 22 def test_import_hooks():
23 23 from IPython.core import hooks
24 24
25 def test_import_ipapi():
26 from IPython.core import ipapi
27
25 28
26 29
@@ -10,8 +10,8 b' See the idoctest docstring below for usage details.'
10 10 import doctest
11 11 import sys
12 12
13 import IPython.ipapi
14 ip = IPython.ipapi.get()
13 from IPython.core import ipapi
14 ip = ipapi.get()
15 15
16 16 def rundoctest(text,ns=None,eraise=False):
17 17 """Run a the input source as a doctest, in the caller's namespace.
@@ -28,7 +28,7 b' import re'
28 28 import __builtin__
29 29
30 30 from IPython.ipmaker import make_IPython
31 from IPython.ipapi import IPApi
31 from IPython.core.ipapi import IPApi
32 32 from IPython.kernel.core.redirector_output_trap import RedirectorOutputTrap
33 33
34 34 from IPython.kernel.core.sync_traceback_trap import SyncTracebackTrap
@@ -19,7 +19,7 b' import string'
19 19 from nose.tools import assert_equal
20 20
21 21 from IPython.frontend.prefilterfrontend import PrefilterFrontEnd
22 from IPython.ipapi import get as get_ipython0
22 from IPython.core.ipapi import get as get_ipython0
23 23 from IPython.testing.plugin.ipdoctest import default_argv
24 24
25 25
@@ -184,8 +184,8 b' class NonBlockingIPShell(object):'
184 184 self._IP.user_ns['help'] = _Helper(self._pager_help)
185 185
186 186 #we disable cpase magic... until we found a way to use it properly.
187 #import IPython.ipapi
188 ip = IPython.ipapi.get()
187 from IPython.core import ipapi
188 ip = ipapi.get()
189 189 def bypass_magic(self, arg):
190 190 print '%this magic is currently disabled.'
191 191 ip.expose_magic('cpaste', bypass_magic)
@@ -19,7 +19,7 b' except ImportError:'
19 19 is_sync_frontend_ok = False
20 20
21 21 #used to create options.conf file in user directory
22 from IPython.ipapi import get
22 from IPython.core.ipapi import get
23 23
24 24 __version__ = 0.91
25 25 __author__ = "Laurent Dufrechou"
@@ -57,7 +57,7 b' from IPython.ipstruct import Struct'
57 57 from IPython.lib.backgroundjobs import BackgroundJobManager
58 58 from IPython.utils.genutils import *
59 59 from IPython.strdispatch import StrDispatch
60 import IPython.ipapi
60 from IPython.core import ipapi
61 61 import IPython.core.history
62 62 import IPython.prefilter as prefilter
63 63 import IPython.shadowns
@@ -463,7 +463,7 b' class InteractiveShell(object,Magic):'
463 463 # These routines return properly built dicts as needed by the rest of
464 464 # the code, and can also be used by extension writers to generate
465 465 # properly initialized namespaces.
466 user_ns, user_global_ns = IPython.ipapi.make_user_namespaces(user_ns,
466 user_ns, user_global_ns = ipapi.make_user_namespaces(user_ns,
467 467 user_global_ns)
468 468
469 469 # Assign namespaces
@@ -783,7 +783,7 b' class InteractiveShell(object,Magic):'
783 783 self.auto_alias = [s.split(None,1) for s in auto_alias]
784 784
785 785 # Produce a public API instance
786 self.api = IPython.ipapi.IPApi(self)
786 self.api = ipapi.IPApi(self)
787 787
788 788 # Initialize all user-visible namespaces
789 789 self.init_namespaces()
@@ -1592,7 +1592,7 b' class InteractiveShell(object,Magic):'
1592 1592 try:
1593 1593 self.hooks.fix_error_editor(e.filename,
1594 1594 int0(e.lineno),int0(e.offset),e.msg)
1595 except IPython.ipapi.TryNext:
1595 except ipapi.TryNext:
1596 1596 warn('Could not open editor')
1597 1597 return False
1598 1598 return True
@@ -1706,7 +1706,7 b' class InteractiveShell(object,Magic):'
1706 1706
1707 1707 if etype is SyntaxError:
1708 1708 self.showsyntaxerror(filename)
1709 elif etype is IPython.ipapi.UsageError:
1709 elif etype is ipapi.UsageError:
1710 1710 print "UsageError:", value
1711 1711 else:
1712 1712 # WARNING: these variables are somewhat deprecated and not
@@ -2548,7 +2548,7 b' class InteractiveShell(object,Magic):'
2548 2548 self.log(line,line,continue_prompt)
2549 2549 return line
2550 2550
2551 force_auto = isinstance(obj, IPython.ipapi.IPyAutocall)
2551 force_auto = isinstance(obj, ipapi.IPyAutocall)
2552 2552 auto_rewrite = True
2553 2553
2554 2554 if pre == self.ESC_QUOTE:
@@ -27,7 +27,7 b' import sys'
27 27 from twisted.internet.error import ConnectionRefusedError
28 28
29 29 from IPython.ultraTB import _fixed_getinnerframes, findsource
30 from IPython import ipapi
30 from IPython.core import ipapi
31 31
32 32 from IPython.kernel import error
33 33
@@ -108,7 +108,7 b' class RemoteContextBase(object):'
108 108 return strip_whitespace(wsource)
109 109
110 110 def _findsource_ipython(self,f):
111 from IPython import ipapi
111 from IPython.core import ipapi
112 112 self.ip = ipapi.get()
113 113 buf = self.ip.IP.input_hist_raw[-1].splitlines()[1:]
114 114 wsource = [l+'\n' for l in buf ]
@@ -29,7 +29,7 b' from IPython.external.Itpl import ItplNS'
29 29
30 30 from IPython.utils import coloransi
31 31 from IPython import Release
32 from IPython.ipapi import TryNext
32 from IPython.core.ipapi import TryNext
33 33 from IPython.utils.genutils import *
34 34 import IPython.utils.generics
35 35
@@ -312,7 +312,7 b' class InteractiveMultiEngineClient(object):'
312 312 return strip_whitespace(wsource)
313 313
314 314 def findsource_ipython(self,f):
315 from IPython import ipapi
315 from IPython.core import ipapi
316 316 self.ip = ipapi.get()
317 317 wsource = [l+'\n' for l in
318 318 self.ip.IP.input_hist_raw[-1].splitlines()[1:]]
@@ -7,10 +7,10 b''
7 7 # the file COPYING, distributed as part of this software.
8 8 #*****************************************************************************
9 9
10 import IPython.ipapi
10 from IPython.core import ipapi
11 11
12 12 from IPython.utils.genutils import Term
13 from IPython.ipapi import IPyAutocall
13 from IPython.core.ipapi import IPyAutocall
14 14
15 15 class Macro(IPyAutocall):
16 16 """Simple class to store the value of macros as strings.
@@ -8,7 +8,7 b' transforming work.'
8 8 __docformat__ = "restructuredtext en"
9 9
10 10 import re
11 import IPython.ipapi
11 from IPython.core import ipapi
12 12
13 13 class LineInfo(object):
14 14 """A single line of input and associated info.
@@ -178,7 +178,7 b' def checkEmacs(l_info,ip):'
178 178 def checkIPyAutocall(l_info,ip):
179 179 "Instances of IPyAutocall in user_ns get autocalled immediately"
180 180 obj = ip.user_ns.get(l_info.iFun, None)
181 if isinstance(obj, IPython.ipapi.IPyAutocall):
181 if isinstance(obj, ipapi.IPyAutocall):
182 182 obj.set_ip(ip.api)
183 183 return ip.handle_auto
184 184 else:
@@ -62,8 +62,8 b' import unittest'
62 62
63 63 from doctest import *
64 64
65 # Our own imports
66 65 from IPython.tools import utils
66 from IPython.core import ipapi
67 67
68 68 ###########################################################################
69 69 #
@@ -85,7 +85,7 b' sys.displayhook = sys.__displayhook__'
85 85 sys.excepthook = sys.__excepthook__
86 86
87 87 # So that ipython magics and aliases can be doctested
88 __builtin__._ip = IPython.ipapi.get()
88 __builtin__._ip = ipapi.get()
89 89
90 90 # for debugging only!!!
91 91 #from IPython.Shell import IPShellEmbed;ipshell=IPShellEmbed(['--noterm_title']) # dbg
@@ -164,6 +164,7 b' def start_ipython():'
164 164 import new
165 165
166 166 import IPython
167 from IPython.core import ipapi
167 168
168 169 def xsys(cmd):
169 170 """Execute a command and print its output.
@@ -183,7 +184,7 b' def start_ipython():'
183 184 argv = default_argv()
184 185
185 186 # Start IPython instance. We customize it to start with minimal frills.
186 user_ns,global_ns = IPython.ipapi.make_user_namespaces(ipnsdict(),dict())
187 user_ns,global_ns = ipapi.make_user_namespaces(ipnsdict(),dict())
187 188 IPython.Shell.IPShell(argv,user_ns,global_ns)
188 189
189 190 # Deactivate the various python system hooks added by ipython for
@@ -18,7 +18,7 b' test_magic.py calls it.'
18 18 #-----------------------------------------------------------------------------
19 19 import sys
20 20
21 from IPython import ipapi
21 from IPython.core import ipapi
22 22
23 23 #-----------------------------------------------------------------------------
24 24 # Globals
@@ -13,7 +13,8 b' import tempfile'
13 13 import nose.tools as nt
14 14
15 15 # our own packages
16 from IPython import ipapi, iplib
16 from IPython import iplib
17 from IPython.core import ipapi
17 18
18 19 #-----------------------------------------------------------------------------
19 20 # Globals
@@ -15,7 +15,7 b' Here is an example from genutils.py:'
15 15 can use the niftier decorator syntax introduced in Python 2.4).
16 16 '''
17 17
18 from IPython.ipapi import TryNext
18 from IPython.core.ipapi import TryNext
19 19 from IPython.external.simplegeneric import generic
20 20
21 21 def result_display(result):
@@ -50,7 +50,7 b' from IPython.Itpl import Itpl,itpl,printpl'
50 50 from IPython import platutils
51 51 from IPython.utils import DPyGetOpt
52 52 from IPython.utils.generics import result_display
53 import IPython.ipapi
53 from IPython.core import ipapi
54 54 from IPython.external.path import path
55 55 if os.name == "nt":
56 56 from IPython.winconsole import get_console_size
@@ -1625,12 +1625,12 b' def page(strng,start=0,screen_lines=0,pager_cmd = None):'
1625 1625 start = max(0,start)
1626 1626
1627 1627 # first, try the hook
1628 ip = IPython.ipapi.get()
1628 ip = ipapi.get()
1629 1629 if ip:
1630 1630 try:
1631 1631 ip.IP.hooks.show_in_pager(strng)
1632 1632 return
1633 except IPython.ipapi.TryNext:
1633 except ipapi.TryNext:
1634 1634 pass
1635 1635
1636 1636 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
General Comments 0
You need to be logged in to leave comments. Login now