Show More
@@ -62,7 +62,7 b' def parse_py(s, **kwargs):' | |||||
62 |
|
62 | |||
63 | def reads_json(s, **kwargs): |
|
63 | def reads_json(s, **kwargs): | |
64 | """Read a JSON notebook from a string and return the NotebookNode object.""" |
|
64 | """Read a JSON notebook from a string and return the NotebookNode object.""" | |
65 |
return convert(reader.reads( |
|
65 | return convert(reader.reads(s), current_nbformat) | |
66 |
|
66 | |||
67 |
|
67 | |||
68 | def writes_json(nb, **kwargs): |
|
68 | def writes_json(nb, **kwargs): |
@@ -18,9 +18,15 b' Authors:' | |||||
18 |
|
18 | |||
19 | import json |
|
19 | import json | |
20 |
|
20 | |||
21 | versions = {} |
|
21 | import v1 | |
22 | for i in range(3): |
|
22 | import v2 | |
23 | versions[i+1] = __import__('v{0}'.format(i+1)) |
|
23 | import v3 | |
|
24 | ||||
|
25 | versions = { | |||
|
26 | 1: v1, | |||
|
27 | 2: v2, | |||
|
28 | 3: v3, | |||
|
29 | } | |||
24 |
|
30 | |||
25 | #----------------------------------------------------------------------------- |
|
31 | #----------------------------------------------------------------------------- | |
26 | # Code |
|
32 | # Code | |
@@ -76,7 +82,7 b" def reads(s, format='ipynb', **kwargs):" | |||||
76 | nb_dict = parse_json(s, **kwargs) |
|
82 | nb_dict = parse_json(s, **kwargs) | |
77 | (major, minor) = get_version(nb_dict) |
|
83 | (major, minor) = get_version(nb_dict) | |
78 | if major in versions: |
|
84 | if major in versions: | |
79 | return versions[major].to_notebook_json(nb, minor=minor) |
|
85 | return versions[major].to_notebook_json(nb_dict, minor=minor) | |
80 | else: |
|
86 | else: | |
81 | raise NBFormatError('Unsupported nbformat version %s' % major) |
|
87 | raise NBFormatError('Unsupported nbformat version %s' % major) | |
82 |
|
88 |
@@ -20,4 +20,4 b' from .nbjson import reads as reads_json, writes as writes_json' | |||||
20 | from .nbjson import reads as read_json, writes as write_json |
|
20 | from .nbjson import reads as read_json, writes as write_json | |
21 | from .nbjson import to_notebook as to_notebook_json |
|
21 | from .nbjson import to_notebook as to_notebook_json | |
22 |
|
22 | |||
23 |
from .convert import |
|
23 | from .convert import upgrade |
General Comments 0
You need to be logged in to leave comments.
Login now