From 4c6fbd8177a7499608b177d64297dc5117a8dd9a Mon Sep 17 00:00:00 2001 From: mkaay Date: Fri, 7 May 2010 17:31:29 +0200 Subject: UploadedTo account plugin --- module/plugins/Account.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'module/plugins/Account.py') 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 -- cgit v1.2.3