Show More
@@ -693,17 +693,17 b' class CodeMagics(Magics):' | |||||
693 | # Quote filenames that may have spaces in them when opening |
|
693 | # Quote filenames that may have spaces in them when opening | |
694 | # the editor |
|
694 | # the editor | |
695 | quoted = filename = str(filepath.absolute()) |
|
695 | quoted = filename = str(filepath.absolute()) | |
696 |
if |
|
696 | if " " in quoted: | |
697 | quoted = "'%s'" % quoted |
|
697 | quoted = "'%s'" % quoted | |
698 | self.shell.hooks.editor(quoted,lineno) |
|
698 | self.shell.hooks.editor(quoted, lineno) | |
699 | except TryNext: |
|
699 | except TryNext: | |
700 | warn('Could not open editor') |
|
700 | warn('Could not open editor') | |
701 | return |
|
701 | return | |
702 |
|
702 | |||
703 | # XXX TODO: should this be generalized for all string vars? |
|
703 | # XXX TODO: should this be generalized for all string vars? | |
704 | # For now, this is special-cased to blocks created by cpaste |
|
704 | # For now, this is special-cased to blocks created by cpaste | |
705 |
if args.strip() == |
|
705 | if args.strip() == "pasted_block": | |
706 |
self.shell.user_ns[ |
|
706 | self.shell.user_ns["pasted_block"] = filepath.read_text() | |
707 |
|
707 | |||
708 | if 'x' in opts: # -x prevents actual execution |
|
708 | if 'x' in opts: # -x prevents actual execution | |
709 | print() |
|
709 | print() | |
@@ -713,8 +713,7 b' class CodeMagics(Magics):' | |||||
713 | if not is_temp: |
|
713 | if not is_temp: | |
714 | self.shell.user_ns['__file__'] = filename |
|
714 | self.shell.user_ns['__file__'] = filename | |
715 | if 'r' in opts: # Untranslated IPython code |
|
715 | if 'r' in opts: # Untranslated IPython code | |
716 |
|
|
716 | source = filepath.read_text() | |
717 | source = f.read() |
|
|||
718 | self.shell.run_cell(source, store_history=False) |
|
717 | self.shell.run_cell(source, store_history=False) | |
719 | else: |
|
718 | else: | |
720 | self.shell.safe_execfile(filename, self.shell.user_ns, |
|
719 | self.shell.safe_execfile(filename, self.shell.user_ns, | |
@@ -722,8 +721,7 b' class CodeMagics(Magics):' | |||||
722 |
|
721 | |||
723 | if is_temp: |
|
722 | if is_temp: | |
724 | try: |
|
723 | try: | |
725 |
|
|
724 | return filepath.read_text() | |
726 | return f.read() |
|
|||
727 | except IOError as msg: |
|
725 | except IOError as msg: | |
728 | if Path(msg.filename) == filepath: |
|
726 | if Path(msg.filename) == filepath: | |
729 | warn('File not found. Did you forget to save?') |
|
727 | warn('File not found. Did you forget to save?') |
General Comments 0
You need to be logged in to leave comments.
Login now