Previous version appeared to rely on integer division as implemented in py2 and would return a float regardless of flating_point argument in py3.
Vlad Presnyak authored on 2018/07/18 05:13:39... | ... |
@@ -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 = floating_point and float(size) or int(size) |
|
195 |
+ size = 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 (size, coeff) |
|
202 |
+ return (float(size) if floating_point else int(size), coeff) |
|
203 | 203 |
else: |
204 |
- return (size, "") |
|
204 |
+ return (float(size) if floating_point else int(size), "") |
|
205 | 205 |
__all__.append("formatSize") |
206 | 206 |
|
207 | 207 |
def formatDateTime(s3timestamp): |