summaryrefslogtreecommitdiff
path: root/UpdateManager/Common/utils.py
diff options
context:
space:
mode:
authorSebastian Heinlein <sebi@sebi-pc>2006-09-27 00:21:17 +0200
committerSebastian Heinlein <sebi@sebi-pc>2006-09-27 00:21:17 +0200
commit84593d761ff3e297753111923e621dfaf9c9ff77 (patch)
treeeeece334e32181c7454a1e6b38df985a85c79480 /UpdateManager/Common/utils.py
parent958de6edfbf38390aa6ee613c9d1d1d70bd5fcb5 (diff)
downloadpython-apt-84593d761ff3e297753111923e621dfaf9c9ff77.tar.gz
* move the humanize_size method to common.utils
* make the strings in the download progress less cryptic for the translators - fix #62494 * Remove the "unkown speed" - just don't display any
Diffstat (limited to 'UpdateManager/Common/utils.py')
-rw-r--r--UpdateManager/Common/utils.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/UpdateManager/Common/utils.py b/UpdateManager/Common/utils.py
index 099cbfed..95440e44 100644
--- a/UpdateManager/Common/utils.py
+++ b/UpdateManager/Common/utils.py
@@ -21,3 +21,20 @@ def error(parent, summary, message):
res = d.run()
d.destroy()
return
+
+def humanize_size(self, bytes):
+ """
+ Convert a given size in bytes to a nicer better readable unit
+ """
+ if bytes == 0:
+ # TRANSLATORS: download size is 0
+ return _("None")
+ elif bytes < 1024:
+ # TRANSLATORS: download size of very small updates
+ return _("1 KB")
+ elif bytes < 1024 * 1024:
+ # TRANSLATORS: download size of small updates, e.g. "250 KB"
+ return locale.format(_("%.0f KB"), bytes/1024)
+ else:
+ # TRANSLATORS: download size of updates, e.g. "2.3 MB"
+ return locale.format(_("%.1f MB"), bytes / 1024 / 1024)