def save_notebook(self, model, name='', path=''): """ Save notebook model to file system. Note: This differs from the NotebookManager.save_notebook in that it doesn't have a rename check. """ if not self.is_writable(name, path): raise Exception("Notebook target is not writable") bundle_path = self._get_bundle_path(name, path) if not os.path.exists(bundle_path): os.mkdir(bundle_path) # Save the notebook file nb = current.to_notebook_json(model['content']) #self.check_and_sign(nb, name, path) notary = sign.NotebookNotary() if notary.check_cells(nb): notary.sign(nb) self.write_notebook(bundle_path, name, nb) if '__files' in model: self.write_files(bundle_path, model)
def setUp(self): self.notary = sign.NotebookNotary( secret=b'secret', profile_dir=get_ipython().profile_dir) with self.fopen(u'test3.ipynb', u'r') as f: self.nb = read(f, as_version=4) with self.fopen(u'test3.ipynb', u'r') as f: self.nb3 = read(f, as_version=3)
def _notary_default(self): return sign.NotebookNotary(parent=self)