##// END OF EJS Templates
Fix up magic_edit functions so they work again.
Thomas Kluyver -
Show More
@@ -2245,7 +2245,7 b' Currently the magic system has the following functions:\\n"""'
2245 filename = self.shell.mktempfile(data)
2245 filename = self.shell.mktempfile(data)
2246 print 'IPython will make a temporary file named:',filename
2246 print 'IPython will make a temporary file named:',filename
2247
2247
2248 return filename
2248 return filename, lineno, use_temp
2249
2249
2250 def _edit_macro(self,mname,macro):
2250 def _edit_macro(self,mname,macro):
2251 """open an editor with the macro data in a file"""
2251 """open an editor with the macro data in a file"""
@@ -2407,7 +2407,7 b' Currently the magic system has the following functions:\\n"""'
2407 opts,args = self.parse_options(parameter_s,'prxn:')
2407 opts,args = self.parse_options(parameter_s,'prxn:')
2408
2408
2409 try:
2409 try:
2410 filename = self._find_edit_target(args, opts, last_call)
2410 filename, lineno, is_temp = self._find_edit_target(args, opts, last_call)
2411 except MacroToEdit as e:
2411 except MacroToEdit as e:
2412 self._edit_macro(args, e.args[0])
2412 self._edit_macro(args, e.args[0])
2413 return
2413 return
@@ -2433,15 +2433,14 b' Currently the magic system has the following functions:\\n"""'
2433 print
2433 print
2434 else:
2434 else:
2435 print 'done. Executing edited code...'
2435 print 'done. Executing edited code...'
2436 if opts_raw:
2436 if 'r' in opts: # Untranslated IPython code
2437 self.shell.run_cell(file_read(filename),
2437 self.shell.run_cell(file_read(filename),
2438 store_history=False)
2438 store_history=False)
2439 else:
2439 else:
2440 self.shell.safe_execfile(filename,self.shell.user_ns,
2440 self.shell.safe_execfile(filename,self.shell.user_ns,
2441 self.shell.user_ns)
2441 self.shell.user_ns)
2442
2443
2442
2444 if use_temp:
2443 if is_temp:
2445 try:
2444 try:
2446 return open(filename).read()
2445 return open(filename).read()
2447 except IOError,msg:
2446 except IOError,msg:
@@ -29,6 +29,7 b' from IPython.core.autocall import ZMQExitAutocall'
29 from IPython.core.displayhook import DisplayHook
29 from IPython.core.displayhook import DisplayHook
30 from IPython.core.displaypub import DisplayPublisher
30 from IPython.core.displaypub import DisplayPublisher
31 from IPython.core.macro import Macro
31 from IPython.core.macro import Macro
32 from IPython.core.magic import MacroToEdit
32 from IPython.core.payloadpage import install_payload_page
33 from IPython.core.payloadpage import install_payload_page
33 from IPython.utils import io
34 from IPython.utils import io
34 from IPython.utils.path import get_py_filename
35 from IPython.utils.path import get_py_filename
@@ -398,11 +399,14 b' class ZMQInteractiveShell(InteractiveShell):'
398 starting example for further modifications. That file also has
399 starting example for further modifications. That file also has
399 general instructions on how to set a new hook for use once you've
400 general instructions on how to set a new hook for use once you've
400 defined it."""
401 defined it."""
402
403 opts,args = self.parse_options(parameter_s,'prn:')
404
401 try:
405 try:
402 filename = self._find_edit_target(args, opts, last_call)
406 filename, lineno, _ = self._find_edit_target(args, opts, last_call)
403 except MacroToEdit as e:
407 except MacroToEdit as e:
404 # TODO: Implement macro editing over 2 processes.
408 # TODO: Implement macro editing over 2 processes.
405 print "Macro editing not yet implemented in 2-process model."
409 print("Macro editing not yet implemented in 2-process model.")
406 return
410 return
407
411
408 # Make sure we send to the client an absolute path, in case the working
412 # Make sure we send to the client an absolute path, in case the working
General Comments 0
You need to be logged in to leave comments. Login now