mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 02:08:54 +00:00
human-readable representation of stats
This commit is contained in:
parent
66bfc6fce8
commit
28d0a9ce84
2 changed files with 8 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue