diff --git a/IPython/nbformat/current.py b/IPython/nbformat/current.py index 16a4938..0df9f23 100644 --- a/IPython/nbformat/current.py +++ b/IPython/nbformat/current.py @@ -62,7 +62,7 @@ def parse_py(s, **kwargs): def reads_json(s, **kwargs): """Read a JSON notebook from a string and return the NotebookNode object.""" - return convert(reader.reads(nb), current_nbformat) + return convert(reader.reads(s), current_nbformat) def writes_json(nb, **kwargs): diff --git a/IPython/nbformat/reader.py b/IPython/nbformat/reader.py index 23d15ed..7993cd5 100644 --- a/IPython/nbformat/reader.py +++ b/IPython/nbformat/reader.py @@ -18,9 +18,15 @@ Authors: import json -versions = {} -for i in range(3): - versions[i+1] = __import__('v{0}'.format(i+1)) +import v1 +import v2 +import v3 + +versions = { + 1: v1, + 2: v2, + 3: v3, + } #----------------------------------------------------------------------------- # Code @@ -76,7 +82,7 @@ def reads(s, format='ipynb', **kwargs): nb_dict = parse_json(s, **kwargs) (major, minor) = get_version(nb_dict) if major in versions: - return versions[major].to_notebook_json(nb, minor=minor) + return versions[major].to_notebook_json(nb_dict, minor=minor) else: raise NBFormatError('Unsupported nbformat version %s' % major) diff --git a/IPython/nbformat/v1/__init__.py b/IPython/nbformat/v1/__init__.py index 3f13769..b3a51a6 100644 --- a/IPython/nbformat/v1/__init__.py +++ b/IPython/nbformat/v1/__init__.py @@ -20,4 +20,4 @@ from .nbjson import reads as reads_json, writes as writes_json from .nbjson import reads as read_json, writes as write_json from .nbjson import to_notebook as to_notebook_json -from .convert import downgrade, upgrade +from .convert import upgrade