Show More
@@ -16,6 +16,7 b' builtin.' | |||
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | |
|
18 | 18 | # Stdlib |
|
19 | import io | |
|
19 | 20 | import os |
|
20 | 21 | import re |
|
21 | 22 | import sys |
@@ -25,7 +26,7 b' from pprint import pformat' | |||
|
25 | 26 | from IPython.core import magic_arguments |
|
26 | 27 | from IPython.core import oinspect |
|
27 | 28 | from IPython.core import page |
|
28 | from IPython.core.error import UsageError | |
|
29 | from IPython.core.error import UsageError, StdinNotImplementedError | |
|
29 | 30 | from IPython.core.magic import ( |
|
30 | 31 | Magics, compress_dhist, magics_class, line_magic, cell_magic |
|
31 | 32 | ) |
@@ -699,13 +700,24 b' class OSMagics(Magics):' | |||
|
699 | 700 | """ |
|
700 | 701 | args = magic_arguments.parse_argstring(self.file, line) |
|
701 | 702 | args.filename = unquote_filename(args.filename) |
|
703 | force = args.force | |
|
702 | 704 | |
|
703 | 705 | if os.path.exists(args.filename): |
|
704 |
if |
|
|
705 | print("Overwriting %s" % args.filename) | |
|
706 | else: | |
|
707 | error("%s already exists! Force overwrite with %%%%file -f\n" % args.filename) | |
|
706 | if not force: | |
|
707 | try: | |
|
708 | force = self.shell.ask_yes_no( | |
|
709 | "%s exists, overwrite (y/[n])?", | |
|
710 | default='n' | |
|
711 | ) | |
|
712 | except StdinNotImplementedError: | |
|
713 | force = True | |
|
714 | ||
|
715 | if not force: | |
|
716 | # prompted, but still no | |
|
717 | print "Force overwrite with %%file -f " + args.filename | |
|
708 | 718 | return |
|
719 | ||
|
720 | print("Overwriting %s" % args.filename) | |
|
709 | 721 | else: |
|
710 | 722 | print("Writing %s" % args.filename) |
|
711 | 723 |
General Comments 0
You need to be logged in to leave comments.
Login now