summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-08-02 17:47:44 +0100
committerLars Wirzenius <liw@liw.fi>2011-08-02 17:47:44 +0100
commit2ed74e7b7266b5a978626b2a1299add37818fc48 (patch)
tree059eed72e2ed0cacf63cccb58bcd52c044db67c3
parent0014611f7f756588a27e55947a1286c3b8c2a127 (diff)
downloadseivot-2ed74e7b7266b5a978626b2a1299add37818fc48.tar.gz
Refactor how grouping is done.
-rwxr-xr-xseivots-summary13
1 files changed, 9 insertions, 4 deletions
diff --git a/seivots-summary b/seivots-summary
index 71e88c6..c7ee426 100755
--- a/seivots-summary
+++ b/seivots-summary
@@ -98,13 +98,11 @@ class SeivotsSummary(cliapp.Application):
sys.stderr.write('Ignoring %s: not a proper seivot file\n' %
filename)
- sizes = self.find_initial_sizes(seivots)
- for size in sorted(sizes):
- group = self.find_seivots_in_size_group(seivots, size)
+ for group, caption in self.find_groups(seivots):
group.sort(key=self.getkey)
for op in ['backup', 'restore', 'list_files', 'forget']:
table = self.make_table(group, op)
- table.caption = '%s: %.0f MiB' % (op, self.disksize(size))
+ table.caption = '%s: %s' % (op, caption)
table.write_plaintext(self.output)
self.output.write('\n')
@@ -176,6 +174,13 @@ class SeivotsSummary(cliapp.Application):
def get_size(self, seivot):
return seivot.getint('0', 'backup.new-data')
+ def find_groups(self, seivots):
+ sizes = self.find_initial_sizes(seivots)
+ for size in sizes:
+ group = self.find_seivots_in_size_group(seivots, size)
+ caption = '%.0f MiB' % self.disksize(size)
+ yield group, caption
+
def find_initial_sizes(self, seivots):
return list(set(self.get_size(s) for s in seivots))