1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-03 10:17:40 +00:00

progress indicators: better docstring, minor code improvement

This commit is contained in:
Thomas Waldmann 2015-12-03 14:14:28 +01:00
parent fe6916bd22
commit 887196b00e

View file

@ -898,6 +898,8 @@ def __init__(self, total, step=5, start=0, same_line=False, msg="%3.0f%%", file=
:param total: total amount of items
:param step: step size in percent
:param start: at which percent value to start
:param same_line: if True, emit output always on same line
:param msg: output message, must contain one %f placeholder for the percentage
:param file: output file, default: sys.stderr
"""
self.counter = 0 # 0 .. (total-1)
@ -909,12 +911,10 @@ def __init__(self, total, step=5, start=0, same_line=False, msg="%3.0f%%", file=
self.same_line = same_line
def progress(self, current=None):
if current is None:
current = self.counter
else:
if current is not None:
self.counter = current
pct = self.counter * 100 / self.total
self.counter += 1
pct = current * 100 / self.total
if pct >= self.trigger_at:
self.trigger_at += self.step
return pct