##// END OF EJS Templates
Use Draft4 JSON Schema for v4
Use Draft4 JSON Schema for v4

File last commit:

r18574:a33db513
r18574:a33db513
Show More
nbbase.py
38 lines | 959 B | text/x-python | PythonLexer
"""The basic dict based notebook format.
The Python representation of a notebook is a nested structure of
dictionary subclasses that support attribute access
(IPython.utils.ipstruct.Struct). The functions in this module are merely
helpers to build the structs in the right form.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import pprint
import uuid
from IPython.utils.ipstruct import Struct
from IPython.utils.py3compat import cast_unicode, unicode_type
# Change this when incrementing the nbformat version
nbformat = 4
nbformat_minor = 0
nbformat_schema = 'nbformat.v4.schema.json'
class NotebookNode(Struct):
pass
def from_dict(d):
if isinstance(d, dict):
newd = NotebookNode()
for k,v in d.items():
newd[k] = from_dict(v)
return newd
elif isinstance(d, (tuple, list)):
return [from_dict(i) for i in d]
else:
return d