diff options
Diffstat (limited to 'UpdateManager/Common/utils.py')
| -rw-r--r-- | UpdateManager/Common/utils.py | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/UpdateManager/Common/utils.py b/UpdateManager/Common/utils.py deleted file mode 100644 index 1fcd022f..00000000 --- a/UpdateManager/Common/utils.py +++ /dev/null @@ -1,42 +0,0 @@ -import gtk -from gettext import gettext as _ -import locale - -def str_to_bool(str): - if str == "0" or str.upper() == "FALSE": - return False - return True - -def utf8(str): - return unicode(str, 'latin1').encode('utf-8') - - -def error(parent, summary, message): - d = gtk.MessageDialog(parent=parent, - flags=gtk.DIALOG_MODAL, - type=gtk.MESSAGE_ERROR, - buttons=gtk.BUTTONS_CLOSE) - d.set_markup("<big><b>%s</b></big>\n\n%s" % (summary, message)) - d.realize() - d.window.set_functions(gtk.gdk.FUNC_MOVE) - d.set_title("") - res = d.run() - d.destroy() - return - -def humanize_size(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) |
