1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 09:47:58 +00:00

human-readable representation of stats

This commit is contained in:
Antoine Beaupré 2015-10-16 01:38:53 -04:00
parent 66bfc6fce8
commit 28d0a9ce84
2 changed files with 8 additions and 0 deletions

View file

@ -168,6 +168,12 @@ def update(self, size, csize, unique):
def __str__(self):
return self.summary.format(stats=self, label='This archive:')
def __repr__(self):
fmt = "<{cls} object at {hash:#x} ({self.osize}, {self.csize}, {self.usize})>"
return fmt.format(cls=type(self).__name__,
hash=id(self),
self=self)
@property
def osize_fmt(self):
return format_file_size(self.osize)

View file

@ -442,3 +442,5 @@ def test_stats_format(stats):
"""
s = "{0.osize_fmt}".format(stats)
assert s == "10 B"
# kind of redundant, but id is variable so we can't match reliably
assert stats.__repr__() == '<Statistics object at {:#x} (10, 10, 10)>'.format(id(stats))