"""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 = 'v4.withref.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