Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _notebook_model_from_path(self, path, content=False, format=None):
"""
Build a notebook model from database record.
"""
model = base_model(path)
model["type"] = "notebook"
if self.fs.isfile(path):
model["last_modified"] = model["created"] = self.fs.lstat(path)["ST_MTIME"]
else:
model["last_modified"] = model["created"] = DUMMY_CREATED_DATE
if content:
if not self.fs.isfile(path):
self.no_such_entity(path)
file_content, _ = self.fs.read(path, format)
nb_content = reads(file_content, as_version=NBFORMAT_VERSION)
self.mark_trusted_cells(nb_content, path)
model["format"] = "json"
model["content"] = nb_content
self.validate_notebook_model(model)
return model