From f8cef1fc6f18133b87f152a2c757f52a48852bd0 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 9 May 2013 21:20:17 +0200 Subject: [PATCH] Minor fix for a test case 211 --- lib/core/progress.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/core/progress.py b/lib/core/progress.py index ec9accc37..82a24913f 100644 --- a/lib/core/progress.py +++ b/lib/core/progress.py @@ -75,7 +75,7 @@ class ProgressBar(object): """ if len(self._times) <= ((self._max * 3) / 100) or newAmount > self._max: - eta = 0 + eta = None else: midTime = sum(self._times) / len(self._times) midTimeWithLatest = (midTime + deltaTime) / 2 @@ -85,22 +85,17 @@ class ProgressBar(object): self.update(newAmount) self.draw(eta) - def draw(self, eta=0): + def draw(self, eta=None): """ This method draws the progress bar if it has changed """ if self._progBar != self._oldProgBar: self._oldProgBar = self._progBar - - if eta and self._amount < self._max: - dataToStdout("\r%s %d/%d ETA %s" % (self._progBar, self._amount, self._max, self._convertSeconds(int(eta)))) - else: - dataToStdout("\r%s\r" % (" " * (self._width - 1))) - if self._amount < self._max: - dataToStdout("%s %d/%d" % (self._progBar, self._amount, self._max)) - else: - kb.prependFlag = False + dataToStdout("\r%s %d/%d%s" % (self._progBar, self._amount, self._max, (" ETA %s" % self._convertSeconds(int(eta))) if eta is not None else "")) + if self._amount >= self._max: + dataToStdout("\r%s\r" % (" " * self._width)) + kb.prependFlag = False def __str__(self): """