diff options
author | Tianjie Xu <xunchang@google.com> | 2020-07-06 21:46:48 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-07-06 21:46:48 +0000 |
commit | 4e18ea41094a9bc4e3eb821196d6d0aae6abb2b4 (patch) | |
tree | 048c16c3935bac60f150f676ad8f8d8493248ce1 /scripts/update_payload/format_utils.py | |
parent | 0200e565dd10928131c17d1fd8ec391f8ebbc8ab (diff) | |
parent | 242e33af30f7aa74531d436e1609100aae3b4394 (diff) |
Merge "Merge remote-tracking branch 'aosp/upstream-master' into merge" am: 242e33af30
Original change: undetermined
Change-Id: I86cfa9f968db67daa3a407c0fb14f38b5f5fa114
Diffstat (limited to 'scripts/update_payload/format_utils.py')
-rw-r--r-- | scripts/update_payload/format_utils.py | 8 |
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]) |