Reduce code cognitive complexity
This commit is contained in:
parent
6f6f3cedd9
commit
49de0e520b
1 changed files with 14 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue