From 76787e97afcde8327e67a72a469533f91b617e5b Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Mon, 29 Oct 2012 11:42:59 +0100 Subject: Do not return None from Size.__str__ (#869405) If no value is < 1000, return the value in YBs. --- pyanaconda/storage/size.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'pyanaconda/storage/size.py') diff --git a/pyanaconda/storage/size.py b/pyanaconda/storage/size.py index 757c97b41..0081d5241 100644 --- a/pyanaconda/storage/size.py +++ b/pyanaconda/storage/size.py @@ -212,23 +212,24 @@ class Size(Decimal): newcheck = super(Size, self).__div__(Decimal(factor)) if newcheck < 1000: - if places is not None: - fmt = "%%.%df" % places - retval = fmt % newcheck - else: - retval = self._trimEnd("%f" % newcheck) - - if max_places is not None: - (whole, point, fraction) = retval.partition(".") - if point and len(fraction) > max_places: - if max_places == 0: - retval = whole - else: - retval = "%s.%s" % (whole, fraction[:max_places]) - - if abbr: - return retval + " " + abbr + _("B") + # nice value, use this factor, prefix and abbr + break + + if places is not None: + fmt = "%%.%df" % places + retval = fmt % newcheck + else: + retval = self._trimEnd("%f" % newcheck) + + if max_places is not None: + (whole, point, fraction) = retval.partition(".") + if point and len(fraction) > max_places: + if max_places == 0: + retval = whole else: - return retval + " " + prefix + P_("byte", "bytes", newcheck) + retval = "%s.%s" % (whole, fraction[:max_places]) - return None + if abbr: + return retval + " " + abbr + _("B") + else: + return retval + " " + prefix + P_("byte", "bytes", newcheck) -- cgit