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