This method updates the progress bar
(self, newAmount=0)
| 37 | return "%.2d:%.2d" % (minutes, seconds) |
| 38 | |
| 39 | def update(self, newAmount=0): |
| 40 | """ |
| 41 | This method updates the progress bar |
| 42 | """ |
| 43 | |
| 44 | if newAmount < self._min: |
| 45 | newAmount = self._min |
| 46 | elif newAmount > self._max: |
| 47 | newAmount = self._max |
| 48 | |
| 49 | self._amount = newAmount |
| 50 | |
| 51 | # Figure out the new percent done, round to an integer |
| 52 | diffFromMin = float(self._amount - self._min) |
| 53 | percentDone = (diffFromMin / float(self._span)) * 100.0 |
| 54 | percentDone = round(percentDone) |
| 55 | percentDone = min(100, int(percentDone)) |
| 56 | |
| 57 | # Figure out how many hash bars the percentage should be |
| 58 | allFull = self._width - len("100%% [] %s/%s (ETA 00:00)" % (self._max, self._max)) |
| 59 | numHashes = (percentDone / 100.0) * allFull |
| 60 | numHashes = int(round(numHashes)) |
| 61 | |
| 62 | # Build a progress bar with an arrow of equal signs |
| 63 | if numHashes == 0: |
| 64 | self._progBar = "[>%s]" % (" " * (allFull - 1)) |
| 65 | elif numHashes == allFull: |
| 66 | self._progBar = "[%s]" % ("=" * allFull) |
| 67 | else: |
| 68 | self._progBar = "[%s>%s]" % ("=" * (numHashes - 1), " " * (allFull - numHashes)) |
| 69 | |
| 70 | # Add the percentage at the beginning of the progress bar |
| 71 | percentString = getUnicode(percentDone) + "%" |
| 72 | self._progBar = "%s %s" % (percentString, self._progBar) |
| 73 | |
| 74 | def progress(self, newAmount): |
| 75 | """ |
no test coverage detected