##// END OF EJS Templates
CodeMagics._find_edit_target is a static method...
MinRK -
Show More
@@ -174,7 +174,8 b' class CodeMagics(Magics):'
174
174
175 self.shell.set_next_input(contents)
175 self.shell.set_next_input(contents)
176
176
177 def _find_edit_target(self, args, opts, last_call):
177 @staticmethod
178 def _find_edit_target(shell, args, opts, last_call):
178 """Utility method used by magic_edit to find what to edit."""
179 """Utility method used by magic_edit to find what to edit."""
179
180
180 def make_filename(arg):
181 def make_filename(arg):
@@ -203,13 +204,13 b' class CodeMagics(Magics):'
203
204
204 if opts_prev:
205 if opts_prev:
205 args = '_%s' % last_call[0]
206 args = '_%s' % last_call[0]
206 if not self.shell.user_ns.has_key(args):
207 if not shell.user_ns.has_key(args):
207 args = last_call[1]
208 args = last_call[1]
208
209
209 # use last_call to remember the state of the previous call, but don't
210 # use last_call to remember the state of the previous call, but don't
210 # let it be clobbered by successive '-p' calls.
211 # let it be clobbered by successive '-p' calls.
211 try:
212 try:
212 last_call[0] = self.shell.displayhook.prompt_count
213 last_call[0] = shell.displayhook.prompt_count
213 if not opts_prev:
214 if not opts_prev:
214 last_call[1] = args
215 last_call[1] = args
215 except:
216 except:
@@ -227,14 +228,14 b' class CodeMagics(Magics):'
227 use_temp = False
228 use_temp = False
228 elif args:
229 elif args:
229 # Mode where user specifies ranges of lines, like in %macro.
230 # Mode where user specifies ranges of lines, like in %macro.
230 data = self.shell.extract_input_lines(args, opts_raw)
231 data = shell.extract_input_lines(args, opts_raw)
231 if not data:
232 if not data:
232 try:
233 try:
233 # Load the parameter given as a variable. If not a string,
234 # Load the parameter given as a variable. If not a string,
234 # process it as an object instead (below)
235 # process it as an object instead (below)
235
236
236 #print '*** args',args,'type',type(args) # dbg
237 #print '*** args',args,'type',type(args) # dbg
237 data = eval(args, self.shell.user_ns)
238 data = eval(args, shell.user_ns)
238 if not isinstance(data, basestring):
239 if not isinstance(data, basestring):
239 raise DataIsObject
240 raise DataIsObject
240
241
@@ -293,7 +294,7 b' class CodeMagics(Magics):'
293 use_temp = False
294 use_temp = False
294
295
295 if use_temp:
296 if use_temp:
296 filename = self.shell.mktempfile(data)
297 filename = shell.mktempfile(data)
297 print 'IPython will make a temporary file named:',filename
298 print 'IPython will make a temporary file named:',filename
298
299
299 return filename, lineno, use_temp
300 return filename, lineno, use_temp
General Comments 0
You need to be logged in to leave comments. Login now