summaryrefslogtreecommitdiff
path: root/obnamlib/plugins/restore_plugin.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-12-24 22:51:41 +0000
committerLars Wirzenius <liw@liw.fi>2013-12-28 21:51:25 +0000
commita1e20b81b2e9ec29582c057fd338e95e97127a3d (patch)
tree3ee98f2f85c1df69a9795bf9b31d99a8ece35297 /obnamlib/plugins/restore_plugin.py
parent0e8ffe0e4209fab408571d3986c3bf03957ef038 (diff)
downloadobnam-a1e20b81b2e9ec29582c057fd338e95e97127a3d.tar.gz
Add RepositoryInterface.walk_generation method
This was already used in two places; it is not unreasonable to expect it to be used in all new places, and duplicating the code is bad.
Diffstat (limited to 'obnamlib/plugins/restore_plugin.py')
-rw-r--r--obnamlib/plugins/restore_plugin.py26
1 files changed, 1 insertions, 25 deletions
diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py
index dffa0f19..bc8b42d3 100644
--- a/obnamlib/plugins/restore_plugin.py
+++ b/obnamlib/plugins/restore_plugin.py
@@ -150,32 +150,8 @@ class RestorePlugin(obnamlib.ObnamPlugin):
if self.errors:
raise obnamlib.Error('There were errors when restoring')
- def repo_walk(self, gen_id, dirname, depth_first=False):
- '''Like os.walk, but for a generation.
-
- This is a generator. Each return value is a tuple consisting
- of a pathname and its corresponding metadata. Directories are
- recursed into.
-
- '''
-
- arg = os.path.normpath(dirname)
- mode = self.repo.get_file_key(
- gen_id, dirname, obnamlib.REPO_FILE_MODE)
- if stat.S_ISDIR(mode):
- if not depth_first:
- yield dirname
- kidpaths = self.repo.get_file_children(gen_id, dirname)
- for kp in kidpaths:
- for x in self.repo_walk(gen_id, kp, depth_first=depth_first):
- yield x
- if depth_first:
- yield arg
- else:
- yield arg
-
def restore_something(self, gen, root):
- for pathname in self.repo_walk(gen, root, depth_first=True):
+ for pathname in self.repo.walk_generation(gen, root):
self.file_count += 1
self.app.ts['current'] = pathname
self.restore_safely(gen, pathname)