summaryrefslogtreecommitdiffstats
path: root/pyload/webui
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/webui')
-rw-r--r--pyload/webui/app/api.py9
-rw-r--r--pyload/webui/filters.py9
2 files changed, 11 insertions, 7 deletions
diff --git a/pyload/webui/app/api.py b/pyload/webui/app/api.py
index 267b9b37c..16e8c2447 100644
--- a/pyload/webui/app/api.py
+++ b/pyload/webui/app/api.py
@@ -14,9 +14,9 @@ from SafeEval import const_eval as literal_eval
from pyload.api import BaseObject
+
# json encoder that accepts TBase objects
class TBaseEncoder(json.JSONEncoder):
-
def default(self, o):
if isinstance(o, BaseObject):
return toDict(o)
@@ -45,7 +45,8 @@ def call_api(func, args=""):
kwargs = {}
for x, y in chain(request.GET.iteritems(), request.POST.iteritems()):
- if x == "session": continue
+ if x == "session":
+ continue
kwargs[x] = unquote(y)
try:
@@ -64,9 +65,7 @@ def callApi(func, *args, **kwargs):
**dict((x, literal_eval(y)) for x, y in kwargs.iteritems()))
# null is invalid json response
- if result is None: result = True
-
- return json.dumps(result, cls=TBaseEncoder)
+ return json.dumps(result or True, cls=TBaseEncoder)
# post -> username, password
diff --git a/pyload/webui/filters.py b/pyload/webui/filters.py
index c784b248d..ea4b159fa 100644
--- a/pyload/webui/filters.py
+++ b/pyload/webui/filters.py
@@ -18,7 +18,7 @@ except Exception:
path_list = abspath(path).split(sep)
# Work out how much of the filepath is shared by start and path.
i = len(commonprefix([start_list, path_list]))
- rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
+ rel_list = [pardir] * (len(start_list) - i) + path_list[i:]
if not rel_list:
return curdir
return join(*rel_list)
@@ -32,6 +32,7 @@ def quotepath(path):
except Exception:
return ""
+
def unquotepath(path):
try:
return path.replace(quotechar, "../")
@@ -40,6 +41,7 @@ def unquotepath(path):
except Exception:
return ""
+
def path_make_absolute(path):
p = os.path.abspath(path)
if p[-1] == os.path.sep:
@@ -47,6 +49,7 @@ def path_make_absolute(path):
else:
return p + os.path.sep
+
def path_make_relative(path):
p = relpath(path)
if p[-1] == os.path.sep:
@@ -54,10 +57,12 @@ def path_make_relative(path):
else:
return p + os.path.sep
+
def truncate(value, n):
if (n - len(value)) < 3:
- return value[:n]+"..."
+ return value[:n] + "..."
return value
+
def date(date, format):
return date