diff options
Diffstat (limited to 'ranger/ext/human_readable.py')
-rw-r--r-- | ranger/ext/human_readable.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ranger/ext/human_readable.py b/ranger/ext/human_readable.py index 40111b6d..3ce6498a 100644 --- a/ranger/ext/human_readable.py +++ b/ranger/ext/human_readable.py @@ -18,11 +18,11 @@ def human_readable(byte, seperator=' '): Convert a large number of bytes to an easily readable format. >>> human_readable(54) - "54 B" + '54 B' >>> human_readable(1500) - "1.46 K" + '1.46 K' >>> human_readable(2 ** 20 * 1023) - "1023 M" + '1023 M' """ if byte <= 0: return '0' @@ -49,3 +49,7 @@ def human_readable(byte, seperator=' '): if byte < 2**60: return '%.4g%sP' % (byte / 2**50.0, seperator) return '>9000' + +if __name__ == '__main__': + import doctest + doctest.testmod() |