From 0585473a9ce52273b246dd79b4e840c9b3b00cc2 2014-04-17 21:19:33 From: Jessica B. Hamrick Date: 2014-04-17 21:19:33 Subject: [PATCH] Use logger string formatting, add some docstrings --- diff --git a/IPython/nbformat/current.py b/IPython/nbformat/current.py index 65abdc9..3f80ea7 100644 --- a/IPython/nbformat/current.py +++ b/IPython/nbformat/current.py @@ -80,21 +80,30 @@ def parse_py(s, **kwargs): def reads_json(s, **kwargs): - """Read a JSON notebook from a string and return the NotebookNode object.""" + """Read a JSON notebook from a string and return the NotebookNode + object. Report if any JSON format errors are detected. + + """ nbjson = reader_reads(s) num_errors = validate(nbjson) if num_errors > 0: logger.error( - "Notebook JSON is invalid (%d errors detected)" % num_errors) + "Notebook JSON is invalid (%d errors detected)", + num_errors) return convert(nbjson, current_nbformat) def writes_json(nb, **kwargs): + """Take a NotebookNode object and write out a JSON string. Report if + any JSON format errors are detected. + + """ nbjson = versions[current_nbformat].writes_json(nb, **kwargs) num_errors = validate(nbjson) if num_errors > 0: logger.error( - "Notebook JSON is invalid (%d errors detected)" % num_errors) + "Notebook JSON is invalid (%d errors detected)", + num_errors) return nbjson