mirror of https://github.com/borgbackup/borg.git
adjust display of --stats
it was broken by recent commits. also remove the __format__() anti-pattern from cache as well.
This commit is contained in:
parent
28d0a9ce84
commit
d666c86bfc
|
@ -201,14 +201,12 @@ class Archive:
|
|||
return format_timedelta(self.end-self.start)
|
||||
|
||||
def __str__(self):
|
||||
buf = '''Archive name: {0.name}
|
||||
return '''Archive name: {0.name}
|
||||
Archive fingerprint: {0.fpr}
|
||||
Start time: {0.start:%c}
|
||||
End time: {0.end:%c}
|
||||
Duration: {0.duration}
|
||||
Number of files: {0.stats.nfiles}
|
||||
{0.cache}'''.format(self)
|
||||
return buf
|
||||
Number of files: {0.stats.nfiles}'''.format(self)
|
||||
|
||||
def __repr__(self):
|
||||
return 'Archive(%r)' % self.name
|
||||
|
|
|
@ -78,20 +78,20 @@ class Cache:
|
|||
self.close()
|
||||
|
||||
def __str__(self):
|
||||
return format(self, """\
|
||||
fmt = """\
|
||||
All archives: {0.total_size:>20s} {0.total_csize:>20s} {0.unique_csize:>20s}
|
||||
|
||||
Unique chunks Total chunks
|
||||
Chunk index: {0.total_unique_chunks:20d} {0.total_chunks:20d}""")
|
||||
Chunk index: {0.total_unique_chunks:20d} {0.total_chunks:20d}"""
|
||||
return fmt.format(self.format_tuple())
|
||||
|
||||
def __format__(self, format_spec):
|
||||
def format_tuple(self):
|
||||
# XXX: this should really be moved down to `hashindex.pyx`
|
||||
Summary = namedtuple('Summary', ['total_size', 'total_csize', 'unique_size', 'unique_csize', 'total_unique_chunks', 'total_chunks'])
|
||||
stats = Summary(*self.chunks.summarize())._asdict()
|
||||
for field in ['total_size', 'total_csize', 'unique_csize']:
|
||||
stats[field] = format_file_size(stats[field])
|
||||
stats = Summary(**stats)
|
||||
return format_spec.format(stats)
|
||||
return Summary(**stats)
|
||||
|
||||
def _confirm(self, message, env_var_override=None):
|
||||
print(message, file=sys.stderr)
|
||||
|
|
|
@ -163,8 +163,7 @@ class Statistics:
|
|||
|
||||
summary = """\
|
||||
Original size Compressed size Deduplicated size
|
||||
{label:15} {stats.osize_fmt:>20s} {stats.csize_fmt:>20s} {stats.usize_fmt:>20s}
|
||||
"""
|
||||
{label:15} {stats.osize_fmt:>20s} {stats.csize_fmt:>20s} {stats.usize_fmt:>20s}"""
|
||||
def __str__(self):
|
||||
return self.summary.format(stats=self, label='This archive:')
|
||||
|
||||
|
|
|
@ -438,8 +438,7 @@ def tests_stats_progress(stats, columns = 80):
|
|||
def test_stats_format(stats):
|
||||
assert str(stats) == """\
|
||||
Original size Compressed size Deduplicated size
|
||||
This archive: 10 B 10 B 10 B
|
||||
"""
|
||||
This archive: 10 B 10 B 10 B"""
|
||||
s = "{0.osize_fmt}".format(stats)
|
||||
assert s == "10 B"
|
||||
# kind of redundant, but id is variable so we can't match reliably
|
||||
|
|
Loading…
Reference in New Issue