##// END OF EJS Templates
MAINT: Return dicts from CheckpointManager.get_checkpoint....
Scott Sanderson -
Show More
@@ -252,7 +252,7 b' class FileCheckpointManager(FileManagerMixin, CheckpointManager):'
252 def get_checkpoint(self, checkpoint_id, path, type):
252 def get_checkpoint(self, checkpoint_id, path, type):
253 """Get the content of a checkpoint.
253 """Get the content of a checkpoint.
254
254
255 Returns a pair of (content, type).
255 Returns a model suitable for passing to ContentsManager.save.
256 """
256 """
257 path = path.strip('/')
257 path = path.strip('/')
258 self.log.info("restoring %s from checkpoint %s", path, checkpoint_id)
258 self.log.info("restoring %s from checkpoint %s", path, checkpoint_id)
@@ -260,9 +260,20 b' class FileCheckpointManager(FileManagerMixin, CheckpointManager):'
260 if not os.path.isfile(os_checkpoint_path):
260 if not os.path.isfile(os_checkpoint_path):
261 self.no_such_checkpoint(path, checkpoint_id)
261 self.no_such_checkpoint(path, checkpoint_id)
262 if type == 'notebook':
262 if type == 'notebook':
263 return self._read_notebook(os_checkpoint_path, as_version=4), None
263 return {
264 'type': type,
265 'content': self._read_notebook(
266 os_checkpoint_path,
267 as_version=4,
268 ),
269 }
264 else:
270 else:
265 return self._read_file(os_checkpoint_path, format=None)
271 content, format = self._read_file(os_checkpoint_path, format=None)
272 return {
273 'type': type,
274 'content': content,
275 'format': format,
276 }
266
277
267 def rename_checkpoint(self, checkpoint_id, old_path, new_path):
278 def rename_checkpoint(self, checkpoint_id, old_path, new_path):
268 """Rename a checkpoint from old_path to new_path."""
279 """Rename a checkpoint from old_path to new_path."""
@@ -523,19 +523,14 b' class ContentsManager(LoggingConfigurable):'
523 """
523 """
524 Restore a checkpoint.
524 Restore a checkpoint.
525 """
525 """
526 type = self.get(path, content=False)['type']
526 return self.save(
527 content, format = self.checkpoint_manager.get_checkpoint(
527 model=self.checkpoint_manager.get_checkpoint(
528 checkpoint_id,
528 checkpoint_id,
529 path,
529 path,
530 type,
530 self.get(path, content=False)['type']
531 ),
532 path=path,
531 )
533 )
532
534
533 model = {
534 'type': type,
535 'content': content,
536 'format': format,
537 }
538 return self.save(model, path)
539
540 def delete_checkpoint(self, checkpoint_id, path):
535 def delete_checkpoint(self, checkpoint_id, path):
541 return self.checkpoint_manager.delete_checkpoint(checkpoint_id, path)
536 return self.checkpoint_manager.delete_checkpoint(checkpoint_id, path)
General Comments 0
You need to be logged in to leave comments. Login now