summaryrefslogtreecommitdiff
path: root/scripts/update_payload/format_utils.py
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2020-07-06 22:32:48 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-07-06 22:32:48 +0000
commit58ed12248d0682fec07dccea96869776b8c011d9 (patch)
tree76401c6ad9d53febb8fc4cc23ea0ddec7ca802c7 /scripts/update_payload/format_utils.py
parentedf19a1009b49b1f129ca67c725a574ae8d265e4 (diff)
parent6d7c31ca10907788e6420c086af5c4342d0ba423 (diff)
Merge "Merge remote-tracking branch 'aosp/upstream-master' into merge" am: 242e33af30 am: 4e18ea4109 am: 557e01c63a am: 6d7c31ca10
Original change: undetermined Change-Id: I6691ba2654a5e81ff49bad46a29ac5d914f2153e
Diffstat (limited to 'scripts/update_payload/format_utils.py')
-rw-r--r--scripts/update_payload/format_utils.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/scripts/update_payload/format_utils.py b/scripts/update_payload/format_utils.py
index 6248ba9b..e73badf3 100644
--- a/scripts/update_payload/format_utils.py
+++ b/scripts/update_payload/format_utils.py
@@ -16,6 +16,8 @@
"""Various formatting functions."""
+from __future__ import division
+
def NumToPercent(num, total, min_precision=1, max_precision=5):
"""Returns the percentage (string) of |num| out of |total|.
@@ -50,7 +52,7 @@ def NumToPercent(num, total, min_precision=1, max_precision=5):
precision = min(min_precision, max_precision)
factor = 10 ** precision
while precision <= max_precision:
- percent = num * 100 * factor / total
+ percent = num * 100 * factor // total
if percent:
break
factor *= 10
@@ -102,8 +104,8 @@ def BytesToHumanReadable(size, precision=1, decimal=False):
magnitude = next_magnitude
if exp != 0:
- whole = size / magnitude
- frac = (size % magnitude) * (10 ** precision) / magnitude
+ whole = size // magnitude
+ frac = (size % magnitude) * (10 ** precision) // magnitude
while frac and not frac % 10:
frac /= 10
return '%d%s %s' % (whole, '.%d' % frac if frac else '', suffixes[exp - 1])