[PATCH] Do not return None from Size.__str__ (#869405)
Vratislav Podzimek
vpodzime at redhat.com
Mon Oct 29 19:15:28 UTC 2012
If no value is < 1000, return the value in YBs.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/storage/size.py | 40 +++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/pyanaconda/storage/size.py b/pyanaconda/storage/size.py
index 757c97b..25247fc 100644
--- a/pyanaconda/storage/size.py
+++ b/pyanaconda/storage/size.py
@@ -208,27 +208,29 @@ class Size(Decimal):
if Decimal(check) < 1000:
return "%s B" % check
- for factor, prefix, abbr in _prefixes:
+ for item in _prefixes:
+ factor, prefix, abbr = item
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)
--
1.7.11.7
More information about the anaconda-patches
mailing list