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