[weboob] [PATCH v3 1/3] Added KiB/MiB/GiB/TiB to get_byte_size

Matthieu Weber mweber+weboob at free.fr
Sat Mar 19 15:55:11 CET 2016


Signed-off-by: Matthieu Weber <mweber+weboob at free.fr>
---
 weboob/tools/misc.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/weboob/tools/misc.py b/weboob/tools/misc.py
index 96444a3..7b8c82c 100644
--- a/weboob/tools/misc.py
+++ b/weboob/tools/misc.py
@@ -52,14 +52,18 @@ def get_bytes_size(size, unit_name):
     r"""Converts a unit and a number into a number of bytes.
 
     >>> get_bytes_size(2, 'KB')
-    2048
+    2048.0
     """
     unit_data = {
         'bytes': 1,
         'KB': 1024,
+        'KiB': 1024,
         'MB': 1024 * 1024,
+        'MiB': 1024 * 1024,
         'GB': 1024 * 1024 * 1024,
+        'GiB': 1024 * 1024 * 1024,
         'TB': 1024 * 1024 * 1024 * 1024,
+        'TiB': 1024 * 1024 * 1024 * 1024,
         }
     return float(size * unit_data.get(unit_name, 1))
 
-- 
2.1.4




More information about the weboob mailing list