diff options
Diffstat (limited to 'module/plugins/Account.py')
-rw-r--r-- | module/plugins/Account.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/module/plugins/Account.py b/module/plugins/Account.py index ab3ad9ec5..2ed2325c9 100644 --- a/module/plugins/Account.py +++ b/module/plugins/Account.py @@ -18,6 +18,7 @@ """ from random import randrange +import re class Account(): __name__ = "Account" @@ -72,3 +73,16 @@ class Account(): else: account = self.register[plugin] return account + + def parseTraffic(self, string): #returns kbyte + string = string.strip().lower() + p = re.compile(r"(\d+[\.,]\d+)(.*)") + m = p.match(string) + if m: + traffic = float(m.group(1).replace(",", ".")) + unit = m.group(2).strip() + if unit == "gb" or unit == "gig" or unit == "gbyte" or unit == "gigabyte": + traffic *= 1024*1024 + elif unit == "mb" or unit == "megabyte" or unit == "mbyte" or unit == "mib": + traffic *= 1024 + return traffic |