diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-08-31 00:18:29 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-08-31 00:18:29 +0100 |
commit | ad71d7061bf28aa91c7326263d95e0144ade1804 (patch) | |
tree | 57c89afff8b3735dfcdc796450e0e9279eb12b8e | |
parent | 84e81bdaaab761107f280c0d48dd4d47928c43f4 (diff) | |
download | python-ttystatus-ad71d7061bf28aa91c7326263d95e0144ade1804.tar.gz |
Fix PercentDone wrt zero division.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ttystatus/percent.py | 2 |
2 files changed, 3 insertions, 0 deletions
@@ -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): |