def _notebook_model_from_path(self, path, content=False, format=None): """ Build a notebook model from database record. """ # path = to_api_path(record['parent_name'] + record['name']) model = base_model(path) model['type'] = 'notebook' #model['last_modified'] = model['created'] = record['created_at'] #model['last_modified'] = model['created'] = DUMMY_CREATED_DATE objs_key = "" if not self.prefix: objs_key = path else: objs_key = self.prefix + '/' + path model['last_modified'] = model['created'] = self.s3fs.get_objs( self.prefix)[objs_key].last_modified if content: if not self.s3fs.isfile(path): self.no_such_entity(path) file_content = self.s3fs.read(path) 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
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) 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
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" full_path = '/'.join([self.fs.prefix_, path]) if self.fs.prefix_ not in path else path if full_path in self._cached_objects: model["last_modified"] = model["created"] = self._cached_objects[full_path]['LastModified'] elif self.fs.isfile(path): model["last_modified"] = model["created"] = self.fs.lstat(path)["ST_MTIME"] else: self.do_error("Not Found", 404) 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