add dosctring to bumblebee.util.bytefmt()
This commit is contained in:
parent
629b3381f2
commit
eca8fbcf22
1 changed files with 10 additions and 0 deletions
|
@ -46,6 +46,16 @@ def execute(cmd, wait=True):
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
def bytefmt(num):
|
def bytefmt(num):
|
||||||
|
"""
|
||||||
|
format a value of bytes to a more human readable pattern
|
||||||
|
example: 15 * 1024 becomes 15KiB
|
||||||
|
|
||||||
|
Args:
|
||||||
|
|
||||||
|
num (int): bytes
|
||||||
|
|
||||||
|
Return: string
|
||||||
|
"""
|
||||||
for unit in ["", "Ki", "Mi", "Gi"]:
|
for unit in ["", "Ki", "Mi", "Gi"]:
|
||||||
if num < 1024.0:
|
if num < 1024.0:
|
||||||
return "{:.2f}{}B".format(num, unit)
|
return "{:.2f}{}B".format(num, unit)
|
||||||
|
|
Loading…
Reference in a new issue