mirror of https://github.com/borgbackup/borg.git
progress indicators: better docstring, minor code improvement
This commit is contained in:
parent
fe6916bd22
commit
887196b00e
|
@ -898,6 +898,8 @@ class ProgressIndicatorPercent:
|
||||||
:param total: total amount of items
|
:param total: total amount of items
|
||||||
:param step: step size in percent
|
:param step: step size in percent
|
||||||
:param start: at which percent value to start
|
: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
|
:param file: output file, default: sys.stderr
|
||||||
"""
|
"""
|
||||||
self.counter = 0 # 0 .. (total-1)
|
self.counter = 0 # 0 .. (total-1)
|
||||||
|
@ -909,12 +911,10 @@ class ProgressIndicatorPercent:
|
||||||
self.same_line = same_line
|
self.same_line = same_line
|
||||||
|
|
||||||
def progress(self, current=None):
|
def progress(self, current=None):
|
||||||
if current is None:
|
if current is not None:
|
||||||
current = self.counter
|
|
||||||
else:
|
|
||||||
self.counter = current
|
self.counter = current
|
||||||
|
pct = self.counter * 100 / self.total
|
||||||
self.counter += 1
|
self.counter += 1
|
||||||
pct = current * 100 / self.total
|
|
||||||
if pct >= self.trigger_at:
|
if pct >= self.trigger_at:
|
||||||
self.trigger_at += self.step
|
self.trigger_at += self.step
|
||||||
return pct
|
return pct
|
||||||
|
|
Loading…
Reference in New Issue