##// END OF EJS Templates
switch to _ip.load -> init_ipython(ip) approach for loading IPython modules
vivainio -
Show More
@@ -21,4 +21,4 b' import clearcmd # %clear'
21
21
22 import ipy_stock_completers
22 import ipy_stock_completers
23
23
24 import IPython.history
24 ip.load('IPython.history')
@@ -2,9 +2,6 b''
2
2
3 """ History related magics and functionality """
3 """ History related magics and functionality """
4
4
5 import IPython.ipapi
6 ip = IPython.ipapi.get(allow_dummy = True)
7
8 import fnmatch
5 import fnmatch
9
6
10 def magic_history(self, parameter_s = ''):
7 def magic_history(self, parameter_s = ''):
@@ -81,13 +78,13 b" def magic_history(self, parameter_s = ''):"
81 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
78 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
82 print inline,
79 print inline,
83
80
84 ip.expose_magic("history",magic_history)
81
85
82
86 def magic_hist(self, parameter_s=''):
83 def magic_hist(self, parameter_s=''):
87 """Alternate name for %history."""
84 """Alternate name for %history."""
88 return self.magic_history(parameter_s)
85 return self.magic_history(parameter_s)
89
86
90 ip.expose_magic("hist",magic_hist)
87
91
88
92 def rep_f(self, arg):
89 def rep_f(self, arg):
93 r""" Repeat a command, or get command to input line for editing
90 r""" Repeat a command, or get command to input line for editing
@@ -116,7 +113,7 b' def rep_f(self, arg):'
116
113
117
114
118 opts,args = self.parse_options(arg,'',mode='list')
115 opts,args = self.parse_options(arg,'',mode='list')
119
116 ip = self.api
120 if not args:
117 if not args:
121 ip.set_next_input(str(ip.user_ns["_"]))
118 ip.set_next_input(str(ip.user_ns["_"]))
122 return
119 return
@@ -134,7 +131,6 b' def rep_f(self, arg):'
134 print "lines",lines
131 print "lines",lines
135 ip.runlines(lines)
132 ip.runlines(lines)
136
133
137 ip.expose_magic("rep",rep_f)
138
134
139 _sentinel = object()
135 _sentinel = object()
140
136
@@ -168,5 +164,10 b' def test_shist():'
168 s.add('hello')
164 s.add('hello')
169 s.add('world')
165 s.add('world')
170 print "all",s.all()
166 print "all",s.all()
167
168 def init_ipython(ip):
169 ip.expose_magic("rep",rep_f)
170 ip.expose_magic("hist",magic_hist)
171 ip.expose_magic("history",magic_history)
171
172
172 # test_shist()
173 # test_shist()
@@ -378,6 +378,14 b' class IPApi:'
378 """
378 """
379
379
380 self.IP.rl_next_input = s
380 self.IP.rl_next_input = s
381
382 def load(self, mod):
383 if mod in sys.modules:
384 return
385 __import__(mod)
386 m = sys.modules[mod]
387 if hasattr(m,'init_ipython'):
388 m.init_ipython(self)
381
389
382
390
383 def launch_new_instance(user_ns = None):
391 def launch_new_instance(user_ns = None):
General Comments 0
You need to be logged in to leave comments. Login now