Show More
@@ -81,7 +81,8 b' class CodeMagics(Magics):' | |||
|
81 | 81 | fname, codefrom = unquote_filename(args[0]), " ".join(args[1:]) |
|
82 | 82 | if not fname.endswith((u'.py',u'.ipy')): |
|
83 | 83 | fname += ext |
|
84 | if os.path.isfile(fname) and not force and not append: | |
|
84 | file_exists = os.path.isfile(fname) | |
|
85 | if file_exists and not force and not append: | |
|
85 | 86 | try: |
|
86 | 87 | overwrite = self.shell.ask_yes_no('File `%s` exists. Overwrite (y/[N])? ' % fname, default='n') |
|
87 | 88 | except StdinNotImplementedError: |
@@ -97,7 +98,7 b' class CodeMagics(Magics):' | |||
|
97 | 98 | return |
|
98 | 99 | out = py3compat.cast_unicode(cmds) |
|
99 | 100 | with io.open(fname, mode, encoding="utf-8") as f: |
|
100 | if not append: | |
|
101 | if not file_exists or not append: | |
|
101 | 102 | f.write(u"# coding: utf-8\n") |
|
102 | 103 | f.write(out) |
|
103 | 104 | # make sure we end on a newline |
General Comments 0
You need to be logged in to leave comments.
Login now