diff --git a/bumblebee_status/modules/core/memory.py b/bumblebee_status/modules/core/memory.py index a4015ff..c9ecf44 100644 --- a/bumblebee_status/modules/core/memory.py +++ b/bumblebee_status/modules/core/memory.py @@ -74,15 +74,22 @@ class Module(core.module.Module): # https://bugs.python.org/issue32933 for line in f.readlines(): tmp = re.split(r"[:\s]+", line) - value = int(tmp[1]) - if tmp[2] == "kB": - value = value * 1024 - if tmp[2] == "mB": - value = value * 1024 * 1024 - if tmp[2] == "gB": - value = value * 1024 * 1024 * 1024 + value = self.__parse_value(tmp) + data[tmp[0]] = value return data + def __parse_value(self, data): + value = int(data[1]) + + if data[2] == "kB": + value = value * 1024 + if data[2] == "mB": + value = value * 1024 * 1024 + if data[2] == "gB": + value = value * 1024 * 1024 * 1024 + + return value + # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4