From eca8fbcf22ef065bf89d254ed1441c6c8c336f71 Mon Sep 17 00:00:00 2001 From: me Date: Sun, 12 Jan 2020 20:24:18 +0200 Subject: [PATCH] add dosctring to bumblebee.util.bytefmt() --- bumblebee/util.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bumblebee/util.py b/bumblebee/util.py index 0d12105..b0ce1c0 100644 --- a/bumblebee/util.py +++ b/bumblebee/util.py @@ -46,6 +46,16 @@ def execute(cmd, wait=True): return rv 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"]: if num < 1024.0: return "{:.2f}{}B".format(num, unit)