##// END OF EJS Templates
Relative import
Jonathan Frederic -
Show More
@@ -29,7 +29,8 b' from IPython.nbformat.v3 import ('
29 29 nbformat_minor,
30 30 )
31 31
32 import reader
32 from .reader import reads as reader_reads
33 from .reader import versions
33 34 from .convert import convert
34 35
35 36 #-----------------------------------------------------------------------------
@@ -62,18 +63,18 b' def parse_py(s, **kwargs):'
62 63
63 64 def reads_json(s, **kwargs):
64 65 """Read a JSON notebook from a string and return the NotebookNode object."""
65 return convert(reader.reads(s), current_nbformat)
66 return convert(reader_reads(s), current_nbformat)
66 67
67 68
68 69 def writes_json(nb, **kwargs):
69 return reader.versions[current_nbformat].writes_json(nb, **kwargs)
70 return versions[current_nbformat].writes_json(nb, **kwargs)
70 71
71 72
72 73 def reads_py(s, **kwargs):
73 74 """Read a .py notebook from a string and return the NotebookNode object."""
74 75 nbf, nbm, s = parse_py(s, **kwargs)
75 76 if nbf == 2 or nbf == 3:
76 nb = reader.versions[nbf].to_notebook_py(s, **kwargs)
77 nb = versions[nbf].to_notebook_py(s, **kwargs)
77 78 else:
78 79 raise NBFormatError('Unsupported PY nbformat version: %i' % nbf)
79 80 return nb
@@ -81,7 +82,7 b' def reads_py(s, **kwargs):'
81 82
82 83 def writes_py(nb, **kwargs):
83 84 # nbformat 3 is the latest format that supports py
84 return reader.versions[3].writes_py(nb, **kwargs)
85 return versions[3].writes_py(nb, **kwargs)
85 86
86 87
87 88 # High level API
General Comments 0
You need to be logged in to leave comments. Login now