diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2017-01-28 15:01:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-28 15:01:45 +0000 |
commit | b66b045225a432c55558634b2f8969c6fb190bd2 (patch) | |
tree | 352fbb8b5962e7e9553ca13490f69739dff51c73 /alot | |
parent | 58a641e43944a424c92175e2dd3b4e86adbb93d1 (diff) | |
parent | 9c552c58299a7e11cf1bcf5c6eb6a0c81aa16c09 (diff) |
Merge pull request #1013 from dcbaker/pr/correct-units
helper: Use kibi and mibibytes instead of kilo and megabytes
Diffstat (limited to 'alot')
-rw-r--r-- | alot/helper.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/alot/helper.py b/alot/helper.py index a60c9ea7..fae4e9f8 100644 --- a/alot/helper.py +++ b/alot/helper.py @@ -511,8 +511,10 @@ def tag_cmp(a, b): def humanize_size(size): """Create a nice human readable representation of the given number - (understood as bytes) using the "K" and "M" suffixes to indicate kilo- and - megabytes. They are understood to be 1024 based. + (understood as bytes) using the "KiB" and "MiB" suffixes to indicate + kibibytes and mebibytes. A kibibyte is defined as 1024 bytes (as opposed to + a kilobyte which is 1000 bytes) and a mibibyte is 1024**2 bytes (as opposed + to a megabyte which is 1000**2 bytes). :param size: the number to convert :type size: int @@ -520,8 +522,8 @@ def humanize_size(size): :rtype: str """ for factor, format_string in ((1, '%i'), - (1024, '%iK'), - (1024 * 1024, '%.1fM')): + (1024, '%iKiB'), + (1024 * 1024, '%.1fMiB')): if size / factor < 1024: return format_string % (float(size) / factor) return format_string % (size / factor) |