def restore(cfg, snapshot_id = None, what = None, where = None, **kwargs): if what is None: what = input('File to restore: ') what = tools.prepare_path(os.path.abspath(os.path.expanduser(what))) if where is None: where = input('Restore to (empty for original path): ') if where: where = tools.prepare_path(os.path.abspath(os.path.expanduser(where))) snapshots_list = snapshots.listSnapshots(cfg) sid = selectSnapshot(snapshots_list, snapshot_id, 'SnapshotID to restore') print('') RestoreDialog(cfg, sid, what, where, **kwargs).run()
def restore(cfg, snapshot_id = None, what = None, where = None, **kwargs): if what is None: what = input('File to restore: ') what = tools.prepare_path(os.path.abspath(os.path.expanduser(what))) if where is None: where = input('Restore to (empty for original path): ') if where: where = tools.prepare_path(os.path.abspath(os.path.expanduser(where))) snapshots_list = snapshots.listSnapshots(cfg) sid = selectSnapshot(snapshots_list, cfg, snapshot_id, 'SnapshotID to restore') print('') RestoreDialog(cfg, sid, what, where, **kwargs).run()
def test_prepare_path(self): """ Test the function load_env """ path_with_slash_at_begin = "/test/path" path_without_slash_at_begin = "test/path" path_with_slash_at_end = "/test/path/" path_without_slash_at_end = "/test/path" self.assertEqual(tools.prepare_path(path_with_slash_at_begin), path_with_slash_at_begin) self.assertEqual(tools.prepare_path(path_without_slash_at_begin), path_with_slash_at_begin) self.assertEqual(tools.prepare_path(path_without_slash_at_end), path_without_slash_at_end) self.assertEqual(tools.prepare_path(path_with_slash_at_end), path_without_slash_at_end)
def test_prepare_path(self): path_with_slash_at_begin = "/test/path" path_without_slash_at_begin = "test/path" path_with_slash_at_end = "/test/path/" path_without_slash_at_end = "/test/path" self.assertEqual( tools.prepare_path(path_with_slash_at_begin), path_with_slash_at_begin) self.assertEqual( tools.prepare_path(path_without_slash_at_begin), path_with_slash_at_begin) self.assertEqual( tools.prepare_path(path_without_slash_at_end), path_without_slash_at_end) self.assertEqual( tools.prepare_path(path_with_slash_at_end), path_without_slash_at_end)
def test_prepare_path(self): """ Test the function load_env """ path_with_slash_at_begin = "/test/path" path_without_slash_at_begin = "test/path" path_with_slash_at_end = "/test/path/" path_without_slash_at_end = "/test/path" self.assertEqual( tools.prepare_path(path_with_slash_at_begin), path_with_slash_at_begin) self.assertEqual( tools.prepare_path(path_without_slash_at_begin), path_with_slash_at_begin) self.assertEqual( tools.prepare_path(path_without_slash_at_end), path_without_slash_at_end) self.assertEqual( tools.prepare_path(path_with_slash_at_end), path_without_slash_at_end)