diff options
author | Daniel Norman <danielnorman@google.com> | 2020-08-31 12:05:45 -0700 |
---|---|---|
committer | Daniel Norman <danielnorman@google.com> | 2020-08-31 12:05:45 -0700 |
commit | 5ef6aa3fa1b0b7d539ed40ba34d9c7a9da330d10 (patch) | |
tree | 798c7a596105ea07027dcb8c2aa748d70ffe673b /scripts/update_payload/format_utils.py | |
parent | 1df8e19776bae4f4bd40d3612ca24d296a61801e (diff) | |
parent | fef48effcd6622b403a194429661f2fbbeb3f047 (diff) |
Merge SP1A.200727.001
Change-Id: If248123aff4ebeac81e4a28632798148af8dc7bd
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]) |