Show More
@@ -2313,12 +2313,25 b' define([' | |||||
2313 | var orig_nbformat = nbmodel.metadata.orig_nbformat; |
|
2313 | var orig_nbformat = nbmodel.metadata.orig_nbformat; | |
2314 | var orig_nbformat_minor = nbmodel.metadata.orig_nbformat_minor; |
|
2314 | var orig_nbformat_minor = nbmodel.metadata.orig_nbformat_minor; | |
2315 | if (orig_nbformat !== undefined && nbmodel.nbformat !== orig_nbformat) { |
|
2315 | if (orig_nbformat !== undefined && nbmodel.nbformat !== orig_nbformat) { | |
2316 | var msg = "This notebook has been converted from an older " + |
|
2316 | var src; | |
2317 | "notebook format (v"+orig_nbformat+") to the current notebook " + |
|
2317 | if (nb.nbformat > nb.orig_nbformat) { | |
2318 | "format (v"+nbmodel.nbformat+"). The next time you save this notebook, the " + |
|
2318 | src = " an older notebook format "; | |
2319 | "newer notebook format will be used and older versions of IPython " + |
|
2319 | } else { | |
2320 | "may not be able to read it. To keep the older version, close the " + |
|
2320 | src = " a newer notebook format "; | |
2321 | "notebook without saving it."; |
|
2321 | } | |
|
2322 | ||||
|
2323 | var msg = "This notebook has been converted from" + src + | |||
|
2324 | "(v"+nb.orig_nbformat+") to the current notebook " + | |||
|
2325 | "format (v"+nb.nbformat+"). The next time you save this notebook, the " + | |||
|
2326 | "current notebook format will be used."; | |||
|
2327 | ||||
|
2328 | if (nb.nbformat > nb.orig_nbformat) { | |||
|
2329 | msg += " Older versions of IPython may not be able to read the new format."; | |||
|
2330 | } else { | |||
|
2331 | msg += " Some features of the original notebook may not be available."; | |||
|
2332 | } | |||
|
2333 | msg += " To preserve the original version, close the " + | |||
|
2334 | "notebook without saving it."; | |||
2322 | dialog.modal({ |
|
2335 | dialog.modal({ | |
2323 | notebook: this, |
|
2336 | notebook: this, | |
2324 | keyboard_manager: this.keyboard_manager, |
|
2337 | keyboard_manager: this.keyboard_manager, | |
@@ -2330,7 +2343,7 b' define([' | |||||
2330 | } |
|
2343 | } | |
2331 | } |
|
2344 | } | |
2332 | }); |
|
2345 | }); | |
2333 |
} else if (orig_nbformat_minor !== undefined && nbmodel.nbformat_minor |
|
2346 | } else if (orig_nbformat_minor !== undefined && nbmodel.nbformat_minor < orig_nbformat_minor) { | |
2334 | var that = this; |
|
2347 | var that = this; | |
2335 | var orig_vs = 'v' + nbmodel.nbformat + '.' + orig_nbformat_minor; |
|
2348 | var orig_vs = 'v' + nbmodel.nbformat + '.' + orig_nbformat_minor; | |
2336 | var this_vs = 'v' + nbmodel.nbformat + '.' + this.nbformat_minor; |
|
2349 | var this_vs = 'v' + nbmodel.nbformat + '.' + this.nbformat_minor; |
@@ -51,6 +51,11 b'' | |||||
51 | "type": "integer", |
|
51 | "type": "integer", | |
52 | "minimum": 1 |
|
52 | "minimum": 1 | |
53 | }, |
|
53 | }, | |
|
54 | "orig_nbformat_minor": { | |||
|
55 | "description": "Original notebook format (minor number) before converting the notebook between versions.", | |||
|
56 | "type": "integer", | |||
|
57 | "minimum": 0 | |||
|
58 | }, | |||
54 | "worksheets" : { |
|
59 | "worksheets" : { | |
55 | "description": "Array of worksheets", |
|
60 | "description": "Array of worksheets", | |
56 | "type": "array", |
|
61 | "type": "array", |
@@ -241,9 +241,11 b' def downgrade(nb):' | |||||
241 | cells = [ downgrade_cell(cell) for cell in nb.pop('cells') ] |
|
241 | cells = [ downgrade_cell(cell) for cell in nb.pop('cells') ] | |
242 | nb.worksheets = [v3.new_worksheet(cells=cells)] |
|
242 | nb.worksheets = [v3.new_worksheet(cells=cells)] | |
243 | nb.metadata.setdefault('name', '') |
|
243 | nb.metadata.setdefault('name', '') | |
244 | nb.metadata.pop('orig_nbformat', None) |
|
244 | ||
245 | nb.metadata.pop('orig_nbformat_minor', None) |
|
|||
246 |
|
||||
247 | # Validate the converted notebook before returning it |
|
245 | # Validate the converted notebook before returning it | |
248 | _warn_if_invalid(nb, v3.nbformat) |
|
246 | _warn_if_invalid(nb, v3.nbformat) | |
|
247 | ||||
|
248 | nb.orig_nbformat = nb.metadata.pop('orig_nbformat', nbformat) | |||
|
249 | nb.orig_nbformat_minor = nb.metadata.pop('orig_nbformat_minor', nbformat_minor) | |||
|
250 | ||||
249 | return nb |
|
251 | return nb |
General Comments 0
You need to be logged in to leave comments.
Login now