[blivet:master 12/20] Get whole unit tuple in loop when searching for correct units.

mulhern amulhern at redhat.com
Tue Dec 23 23:42:25 UTC 2014


Some parts of the tuple are not used. This way, it is unnecessary to name
them and then ignore them.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/size.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/blivet/size.py b/blivet/size.py
index cdf22b2..f37a873 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -355,11 +355,10 @@ class Size(Decimal):
         # If the number is so large that no prefix will satisfy this
         # requirement use the largest prefix.
         limit = _BINARY_FACTOR * min_value
-        for factor, _prefix, abbr in [_EMPTY_PREFIX] + _BINARY_PREFIXES:
-            newcheck = super(Size, self).__div__(Decimal(factor))
+        for unit in [_EMPTY_PREFIX] + _BINARY_PREFIXES:
+            newcheck = super(Size, self).__div__(Decimal(unit.factor))
 
             if abs(newcheck) < limit:
-                # nice value, use this factor, prefix and abbr
                 break
 
         if max_places is not None:
@@ -376,7 +375,7 @@ class Size(Decimal):
                 retval_str = retval_str.replace('.', radix)
 
         # pylint: disable=undefined-loop-variable
-        return retval_str + " " + _makeSpec(abbr, _BYTES_SYMBOL, xlate, lowercase=False)
+        return retval_str + " " + _makeSpec(unit.abbr, _BYTES_SYMBOL, xlate, lowercase=False)
 
     def roundToNearest(self, unit, rounding=ROUND_DEFAULT):
         """
-- 
1.9.3



More information about the anaconda-patches mailing list