summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-08-31 00:18:29 +0100
committerLars Wirzenius <liw@liw.fi>2011-08-31 00:18:29 +0100
commitad71d7061bf28aa91c7326263d95e0144ade1804 (patch)
tree57c89afff8b3735dfcdc796450e0e9279eb12b8e
parent84e81bdaaab761107f280c0d48dd4d47928c43f4 (diff)
downloadpython-ttystatus-ad71d7061bf28aa91c7326263d95e0144ade1804.tar.gz
Fix PercentDone wrt zero division.
-rw-r--r--NEWS1
-rw-r--r--ttystatus/percent.py2
2 files changed, 3 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 5832380..9b556c2 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Version 0.14, released XXXXXXXXXX
* Notifications are written to the standard output, not the terminal.
* A method for printing error messages is provided. They are printed to
the standard error.
+* The `PercentDone` class handles zero total amounts better now.
Version 0.13, released 2011-08-18
---------------------------------
diff --git a/ttystatus/percent.py b/ttystatus/percent.py
index 8914f41..af2935c 100644
--- a/ttystatus/percent.py
+++ b/ttystatus/percent.py
@@ -36,6 +36,8 @@ class PercentDone(ttystatus.Widget):
except ValueError:
done = 0
total = 1
+ if total < 0.001:
+ total = 1
return '%.*f %%' % (self.decimals, 100.0 * done / total)
def update(self, master, width):