Show More
@@ -4,6 +4,7 b'' | |||
|
4 | 4 | import argparse |
|
5 | 5 | from logging import error |
|
6 | 6 | import io |
|
7 | import os | |
|
7 | 8 | from pprint import pformat |
|
8 | 9 | import sys |
|
9 | 10 | from warnings import warn |
@@ -572,6 +573,7 b' Currently the magic system has the following functions:""",' | |||
|
572 | 573 | For example, to export the history to "foo.ipynb" do "%notebook foo.ipynb". |
|
573 | 574 | """ |
|
574 | 575 | args = magic_arguments.parse_argstring(self.notebook, s) |
|
576 | outfname = os.path.expanduser(args.filename) | |
|
575 | 577 | |
|
576 | 578 | from nbformat import write, v4 |
|
577 | 579 | |
@@ -585,7 +587,7 b' Currently the magic system has the following functions:""",' | |||
|
585 | 587 | source=source |
|
586 | 588 | )) |
|
587 | 589 | nb = v4.new_notebook(cells=cells) |
|
588 |
with io.open( |
|
|
590 | with io.open(outfname, "w", encoding="utf-8") as f: | |
|
589 | 591 | write(nb, f, version=4) |
|
590 | 592 | |
|
591 | 593 | @magics_class |
@@ -222,6 +222,7 b' class CodeMagics(Magics):' | |||
|
222 | 222 | fname, codefrom = args[0], " ".join(args[1:]) |
|
223 | 223 | if not fname.endswith(('.py','.ipy')): |
|
224 | 224 | fname += ext |
|
225 | fname = os.path.expanduser(fname) | |
|
225 | 226 | file_exists = os.path.isfile(fname) |
|
226 | 227 | if file_exists and not force and not append: |
|
227 | 228 | try: |
@@ -151,6 +151,7 b' class HistoryMagics(Magics):' | |||
|
151 | 151 | # We don't want to close stdout at the end! |
|
152 | 152 | close_at_end = False |
|
153 | 153 | else: |
|
154 | outfname = os.path.expanduser(outfname) | |
|
154 | 155 | if os.path.exists(outfname): |
|
155 | 156 | try: |
|
156 | 157 | ans = io.ask_yes_no("File %r exists. Overwrite?" % outfname) |
General Comments 0
You need to be logged in to leave comments.
Login now