Show More
@@ -79,18 +79,19 b' def parse_py(s, **kwargs):' | |||||
79 | return nbf, nbm, s |
|
79 | return nbf, nbm, s | |
80 |
|
80 | |||
81 |
|
81 | |||
82 | def reads_json(s, **kwargs): |
|
82 | def reads_json(nbjson, **kwargs): | |
83 | """Read a JSON notebook from a string and return the NotebookNode |
|
83 | """Read a JSON notebook from a string and return the NotebookNode | |
84 | object. Report if any JSON format errors are detected. |
|
84 | object. Report if any JSON format errors are detected. | |
85 |
|
85 | |||
86 | """ |
|
86 | """ | |
87 |
nb |
|
87 | nb = reader_reads(nbjson, **kwargs) | |
88 | num_errors = validate(nbjson) |
|
88 | nb_current = convert(nb, current_nbformat) | |
|
89 | num_errors = validate(nb_current) | |||
89 | if num_errors > 0: |
|
90 | if num_errors > 0: | |
90 | logger.error( |
|
91 | logger.error( | |
91 | "Notebook JSON is invalid (%d errors detected)", |
|
92 | "Notebook JSON is invalid (%d errors detected)", | |
92 | num_errors) |
|
93 | num_errors) | |
93 |
return |
|
94 | return nb_current | |
94 |
|
95 | |||
95 |
|
96 | |||
96 | def writes_json(nb, **kwargs): |
|
97 | def writes_json(nb, **kwargs): | |
@@ -98,12 +99,12 b' def writes_json(nb, **kwargs):' | |||||
98 | any JSON format errors are detected. |
|
99 | any JSON format errors are detected. | |
99 |
|
100 | |||
100 | """ |
|
101 | """ | |
101 | nbjson = versions[current_nbformat].writes_json(nb, **kwargs) |
|
102 | num_errors = validate(nb) | |
102 | num_errors = validate(nbjson) |
|
|||
103 | if num_errors > 0: |
|
103 | if num_errors > 0: | |
104 | logger.error( |
|
104 | logger.error( | |
105 | "Notebook JSON is invalid (%d errors detected)", |
|
105 | "Notebook JSON is invalid (%d errors detected)", | |
106 | num_errors) |
|
106 | num_errors) | |
|
107 | nbjson = versions[current_nbformat].writes_json(nb, **kwargs) | |||
107 | return nbjson |
|
108 | return nbjson | |
108 |
|
109 | |||
109 |
|
110 |
General Comments 0
You need to be logged in to leave comments.
Login now