summaryrefslogtreecommitdiffstats
path: root/pyanaconda/storage/size.py
diff options
context:
space:
mode:
authorVratislav Podzimek <vpodzime@redhat.com>2012-10-29 11:42:59 +0100
committerVratislav Podzimek <vpodzime@redhat.com>2012-11-03 00:02:46 +0100
commit76787e97afcde8327e67a72a469533f91b617e5b (patch)
treeb5b19be6be553da704af7c210a5818cce5c98ad0 /pyanaconda/storage/size.py
parentf5094785000a49a010abf56bc32dfcc083a70144 (diff)
downloadanaconda-76787e97afcde8327e67a72a469533f91b617e5b.tar.gz
anaconda-76787e97afcde8327e67a72a469533f91b617e5b.tar.xz
anaconda-76787e97afcde8327e67a72a469533f91b617e5b.zip
Do not return None from Size.__str__ (#869405)
If no value is < 1000, return the value in YBs.
Diffstat (limited to 'pyanaconda/storage/size.py')
-rw-r--r--pyanaconda/storage/size.py37
1 files changed, 19 insertions, 18 deletions
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)