summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-19 09:38:46 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-19 09:38:46 +0200
commit2fed3b3ffa3a614f71b7c73d213fc874806d656b (patch)
tree73c3983068ff3b2e6d58a26638bb66a3af5d375a /module/plugins/internal
parentSpare fixes (diff)
downloadpyload-2fed3b3ffa3a614f71b7c73d213fc874806d656b.tar.xz
Fix https://github.com/pyload/pyload/issues/2056
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/Account.py8
-rw-r--r--module/plugins/internal/SimpleHoster.py4
-rw-r--r--module/plugins/internal/utils.py42
3 files changed, 27 insertions, 27 deletions
diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py
index 469e27cfa..f883eb25c 100644
--- a/module/plugins/internal/Account.py
+++ b/module/plugins/internal/Account.py
@@ -12,7 +12,7 @@ from module.plugins.internal.utils import compare_time, isiterable, lock, parse_
class Account(Plugin):
__name__ = "Account"
__type__ = "account"
- __version__ = "0.63"
+ __version__ = "0.64"
__status__ = "testing"
__description__ = """Base account plugin"""
@@ -451,10 +451,10 @@ class Account(Plugin):
###########################################################################
- def parse_traffic(self, size, unit="byte"): #@NOTE: Returns kilobytes in 0.4.9
+ def parse_traffic(self, size, unit=None): #@NOTE: Returns kilobytes in 0.4.9
self.log_debug("Size: %s" % size,
- "Unit: %s" % (unit if unit is not "byte" else "N/D"))
- return parse_size(size, unit) / 1024 #@TODO: Remove `/ 1024` in 0.4.10
+ "Unit: %s" % (unit or "N/D"))
+ return parse_size(size, unit or "byte") / 1024 #@TODO: Remove `/ 1024` in 0.4.10
def fail_login(self, msg=_("Login handshake has failed")):
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 8dcabdb6c..248c619a2 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -17,7 +17,7 @@ from module.plugins.internal.utils import (encode, fixup, parse_name, parse_size
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "2.00"
+ __version__ = "2.01"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -190,7 +190,7 @@ class SimpleHoster(Hoster):
info['size'] = parse_size(size)
elif isinstance(info['size'], basestring):
- unit = info['units'] if 'units' in info else None
+ unit = info['units'] if 'units' in info else ""
info['size'] = parse_size(info['size'], unit)
if 'H' in info['pattern']:
diff --git a/module/plugins/internal/utils.py b/module/plugins/internal/utils.py
index f7244f2df..651ccce78 100644
--- a/module/plugins/internal/utils.py
+++ b/module/plugins/internal/utils.py
@@ -77,27 +77,6 @@ def uniqify(seq):
return [x for x in seq if x not in seen and not seen_add(x)]
-def parse_size(value, unit=""): #: returns bytes
- m = re.match(r"([\d.,]+)\s*([\w^_]*)", value.lower())
-
- if m is None:
- return 0
-
- traffic = float(m.group(1).replace(',', '.'))
- unit = (unit.strip().lower() or m.group(2) or "byte")[0]
-
- if unit is "b":
- return int(traffic)
-
- sizes = ['b', 'k', 'm', 'g', 't', 'p', 'e']
- sizemap = dict((u, i * 10) for i, u in enumerate(sizes))
-
- increment = sizemap[unit]
- integer, decimal = map(int, ("%.3f" % traffic).split('.'))
-
- return (integer << increment) + (decimal << increment - 10)
-
-
def fixup(m):
text = m.group(0)
if text[:2] == "&#":
@@ -258,6 +237,27 @@ def parse_name(value, safechar=True):
return fixname(name) if safechar else name
+def parse_size(value, unit=""): #: returns bytes
+ m = re.match(r"([\d.,]+)\s*([\w^_]*)", value.lower())
+
+ if m is None:
+ return 0
+
+ traffic = float(m.group(1).replace(',', '.'))
+ unit = (unit.strip().lower() or m.group(2) or "byte")[0]
+
+ if unit is "b":
+ return int(traffic)
+
+ sizes = ['b', 'k', 'm', 'g', 't', 'p', 'e']
+ sizemap = dict((u, i * 10) for i, u in enumerate(sizes))
+
+ increment = sizemap[unit]
+ integer, decimal = map(int, ("%.3f" % traffic).split('.'))
+
+ return (integer << increment) + (decimal << increment - 10)
+
+
def str2int(value):
try:
return int(value)