From b1d0512f0e20b709858151818ddc508fd00dfe4a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 16 Jan 2021 10:32:48 +0100 Subject: helper: move humanize_size to the only place where it is used --- alot/helper.py | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'alot/helper.py') diff --git a/alot/helper.py b/alot/helper.py index b7c4f5a1..5800841d 100644 --- a/alot/helper.py +++ b/alot/helper.py @@ -406,26 +406,6 @@ def shell_quote(text): return "'%s'" % text.replace("'", """'"'"'""") -def humanize_size(size): - """Create a nice human readable representation of the given number - (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 - :returns: the human readable representation of size - :rtype: str - """ - for factor, format_string in ((1, '%i'), - (1024, '%iKiB'), - (1024 * 1024, '%.1fMiB')): - if size / factor < 1024: - return format_string % (size / factor) - return format_string % (size / factor) - - def parse_mailcap_nametemplate(tmplate='%s'): """this returns a prefix and suffix to be used in the tempfile module for a given mailcap nametemplate string""" -- cgit v1.2.3