1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-23 00:07:38 +00:00

Clean-up helpers.prune_split

This commit is contained in:
Dan Christensen 2014-02-02 23:45:53 -05:00
parent 13863e64f8
commit d3ff6ac25d

View file

@ -92,18 +92,17 @@ def write(self):
def prune_split(archives, pattern, n, skip=[]): def prune_split(archives, pattern, n, skip=[]):
items = {} last = None
keep = [] keep = []
for a in archives: if n == 0:
key = to_localtime(a.ts).strftime(pattern) return keep
items.setdefault(key, []) for a in sorted(archives, key=attrgetter('ts'), reverse=True):
items[key].append(a) period = a.ts.strftime(pattern)
for key, values in sorted(items.items(), reverse=True): if period != last:
if n: last = period
values.sort(key=attrgetter('ts'), reverse=True) if a not in skip:
if values[0] not in skip: keep.append(a)
keep.append(values[0]) if len(keep) == n: break
n -= 1
return keep return keep