diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-08-02 18:19:47 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-08-02 18:19:47 +0100 |
commit | 372538dbe849d2a73ffe05a622187acb81528f6a (patch) | |
tree | 93e2a28417457eead61ff1d446f96c0e57247c10 | |
parent | 4e51b16dc88677dd5ee38eb7a7c7b9d0f75997d4 (diff) | |
download | seivot-372538dbe849d2a73ffe05a622187acb81528f6a.tar.gz |
Improve grouping of seivot results.
-rwxr-xr-x | seivots-summary | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/seivots-summary b/seivots-summary index c7ee426..9c5341a 100755 --- a/seivots-summary +++ b/seivots-summary @@ -167,6 +167,41 @@ class SeivotsSummary(cliapp.Application): cp.set('meta', 'branch', os.path.basename(os.path.dirname(filename))) return cp + def find_groups(self, seivots): + # We group together seivot files that share the following: + # - initial size + # - incremental size + # - profile name + # - encryption used + + def key(s): + def get(section, key, default): + if s.has_option(section, key): + return s.get(section, key) + else: + return default + init = s.getint('0', 'backup.new-data') + inc = s.getint('1', 'backup.new-data') + prof = get('meta', 'profile-name', 'unknown profile') + enc = get('meta', 'encrypted', 'no') + + return init, inc, prof, enc + + def caption(s): + init, inc, prof, enc = key(s) + return ('%s %.0f/%.0f MiB (%s)' % + (prof, self.disksize(init), self.disksize(inc), + 'encrypted' if enc == 'yes' else 'unencrypted')) + + groups = {} + for seivot in seivots: + k = key(seivot) + groups[k] = groups.get(k, []) + [seivot] + + result = [(groups[k], caption(groups[k][0])) for k in groups] + result.sort(key=lambda t: t[1]) + return result + def getkey(self, seivot): return (seivot.getint('meta', 'revision'), seivot.getint('meta', 'larch-revision')) @@ -174,13 +209,6 @@ 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)) |