Browse code

Complete the fix #986 - To satisfy py2 and p3, there should be float before and after the division

Florent Viard authored on 2018/07/22 19:28:41
Showing 1 changed files
... ...
@@ -192,16 +192,16 @@ def dateRFC822toUnix(date):
192 192
 __all__.append("dateRFC822toUnix")
193 193
 
194 194
 def formatSize(size, human_readable = False, floating_point = False):
195
-    size = int(size)
195
+    size = floating_point and float(size) or int(size)
196 196
     if human_readable:
197 197
         coeffs = ['k', 'M', 'G', 'T']
198 198
         coeff = ""
199 199
         while size > 2048:
200 200
             size /= 1024
201 201
             coeff = coeffs.pop(0)
202
-        return (float(size) if floating_point else int(size), coeff)
202
+        return (floating_point and float(size) or int(size), coeff)
203 203
     else:
204
-        return (float(size) if floating_point else int(size), "")
204
+        return (size, "")
205 205
 __all__.append("formatSize")
206 206
 
207 207
 def formatDateTime(s3timestamp):