diff options
Diffstat (limited to 'ranger/ext/human_readable.py')
-rw-r--r-- | ranger/ext/human_readable.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ranger/ext/human_readable.py b/ranger/ext/human_readable.py index 31d5d279..71bc29b8 100644 --- a/ranger/ext/human_readable.py +++ b/ranger/ext/human_readable.py @@ -1,8 +1,10 @@ # This file is part of ranger, the console file manager. # License: GNU GPL version 3, see the file "AUTHORS" for details. +from __future__ import (absolute_import, print_function) -def human_readable(byte, separator=' '): + +def human_readable(byte, separator=' '): # pylint: disable=too-many-return-statements """Convert a large number of bytes to an easily readable format. >>> human_readable(54) @@ -19,7 +21,7 @@ def human_readable(byte, separator=' '): if byte <= 0: return '0' if byte < 2**10: - return '%d%sB' % (byte, separator) + return '%d%sB' % (byte, separator) if byte < 2**10 * 999: return '%.3g%sK' % (byte / 2**10.0, separator) if byte < 2**20: @@ -42,6 +44,7 @@ def human_readable(byte, separator=' '): return '%.4g%sP' % (byte / 2**50.0, separator) return '>9000' + if __name__ == '__main__': import doctest doctest.testmod() |