diff options
author | Android Build Role Account android-build-prod <android-build-team-robot@google.com> | 2020-09-21 23:16:07 +0000 |
---|---|---|
committer | Android Build Role Account android-build-prod <android-build-team-robot@google.com> | 2020-09-21 23:16:07 +0000 |
commit | c0d59af7348f9745e12a8581a05bd3a8fdb472fe (patch) | |
tree | 798c7a596105ea07027dcb8c2aa748d70ffe673b /scripts/update_payload/format_utils.py | |
parent | 1df8e19776bae4f4bd40d3612ca24d296a61801e (diff) | |
parent | 5ef6aa3fa1b0b7d539ed40ba34d9c7a9da330d10 (diff) |
Snap for 6852288 from 5ef6aa3fa1b0b7d539ed40ba34d9c7a9da330d10 to s-keystone-qcom-release
Change-Id: I619850ed167e740c8816851854d07ca7a6019273
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]) |