From a9c98d32cd9826e332ca7d8932e60391e869e66e Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 28 Aug 2021 20:53:57 +0200 Subject: [PATCH] Cleaned up size strings. --- nomadnet/ui/textui/Browser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nomadnet/ui/textui/Browser.py b/nomadnet/ui/textui/Browser.py index 88d467c..ee71f42 100644 --- a/nomadnet/ui/textui/Browser.py +++ b/nomadnet/ui/textui/Browser.py @@ -452,6 +452,10 @@ def size_str(num, suffix='B'): for unit in units: if abs(num) < 1000.0: - return "%3.2f %s%s" % (num, unit, suffix) + if unit == "": + return "%.0f%s%s" % (num, unit, suffix) + else: + return "%.2f%s%s" % (num, unit, suffix) num /= 1000.0 - return "%.2f %s%s" % (num, last_unit, suffix) \ No newline at end of file + + return "%.2f%s%s" % (num, last_unit, suffix) \ No newline at end of file