summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar fedeG <federicogonzalez761@gmail.com> 2015-04-20 22:01:18 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-04-20 23:01:46 +0200
commit1e2e91091664c2fca6a187804b2041eab757dbe3 (patch)
treebd31644da726422a2a076b0b68fcda6a75c982b6
parentPEP-8, Python Zen, refactor and reduce code (part 14 in master module/threads) (diff)
downloadpyload-1e2e91091664c2fca6a187804b2041eab757dbe3.tar.xz
PEP-8, Python Zen, refactor and reduce code (part 15 in master module/webui/app)
Conflicts: pyload/webui/app/api.py pyload/webui/app/cnl.py pyload/webui/app/json.py pyload/webui/app/pyloadweb.py pyload/webui/app/utils.py
-rw-r--r--pyload/webui/app/api.py1
-rw-r--r--pyload/webui/app/cnl.py3
-rw-r--r--pyload/webui/app/json.py5
-rw-r--r--pyload/webui/app/pyloadweb.py27
-rw-r--r--pyload/webui/app/utils.py5
5 files changed, 13 insertions, 28 deletions
diff --git a/pyload/webui/app/api.py b/pyload/webui/app/api.py
index 0e36b7c1f..70d86c112 100644
--- a/pyload/webui/app/api.py
+++ b/pyload/webui/app/api.py
@@ -8,7 +8,6 @@ from bottle import route, request, response, HTTPError
from pyload.webui.app.utils import toDict, set_session
from pyload.webui import PYLOAD
-
from pyload.utils import json
from SafeEval import const_eval as literal_eval
from pyload.api import BaseObject
diff --git a/pyload/webui/app/cnl.py b/pyload/webui/app/cnl.py
index b6cbd6b55..635d4030c 100644
--- a/pyload/webui/app/cnl.py
+++ b/pyload/webui/app/cnl.py
@@ -9,6 +9,7 @@ from base64 import standard_b64decode
from binascii import unhexlify
from bottle import route, request, HTTPError
+
from pyload.webui import PYLOAD, DL_ROOT, JS
@@ -87,7 +88,7 @@ def addcrypted2():
try:
jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
except Exception:
- ## Test for some known js functions to decode
+ # Test for some known js functions to decode
if jk.find("dec") > -1 and jk.find("org") > -1:
org = re.findall(r"var org = ('|\")([^\"']+)", jk)[0][1]
jk = list(org)
diff --git a/pyload/webui/app/json.py b/pyload/webui/app/json.py
index 30778f1f7..3b72cb7ce 100644
--- a/pyload/webui/app/json.py
+++ b/pyload/webui/app/json.py
@@ -9,9 +9,7 @@ from shutil import copyfileobj
from bottle import route, request, HTTPError
from pyload.webui import PYLOAD
-
from pyload.webui.app.utils import login_required, render_to_response, toDict
-
from pyload.utils import decode, formatSize
@@ -227,7 +225,7 @@ def set_captcha():
if task.tid >= 0:
src = "data:image/%s;base64,%s" % (task.type, task.data)
- return {'captcha': True, 'id': task.tid, 'src': src, 'result_type' : task.resultType}
+ return {'captcha': True, 'id': task.tid, 'src': src, 'result_type': task.resultType}
else:
return {'captcha': False}
@@ -307,7 +305,6 @@ def update_accounts():
@route('/json/change_password', method='POST')
def change_password():
-
user = request.POST['user_login']
oldpw = request.POST['login_current_password']
newpw = request.POST['login_new_password']
diff --git a/pyload/webui/app/pyloadweb.py b/pyload/webui/app/pyloadweb.py
index f4edb6bd4..3f2eff279 100644
--- a/pyload/webui/app/pyloadweb.py
+++ b/pyload/webui/app/pyloadweb.py
@@ -231,7 +231,7 @@ def downloads():
@login_required("DOWNLOAD")
def get_download(path):
path = unquote(path).decode("utf8")
- #@TODO some files can not be downloaded
+ # @TODO some files can not be downloaded
root = PYLOAD.getConfigValue("general", "download_folder")
@@ -274,12 +274,12 @@ def config():
data.trafficleft = formatSize(data.trafficleft)
if data.validuntil == -1:
- data.validuntil = _("unlimited")
+ data.validuntil = _("unlimited")
elif not data.validuntil:
- data.validuntil = _("not available")
+ data.validuntil = _("not available")
else:
t = time.localtime(data.validuntil)
- data.validuntil = time.strftime("%d.%m.%Y - %H:%M:%S", t)
+ data.validuntil = time.strftime("%d.%m.%Y - %H:%M:%S", t)
try:
data.options['time'] = data.options['time'][0]
@@ -292,7 +292,8 @@ def config():
data.options['limitdl'] = "0"
return render_to_response('settings.html',
- {'conf': {'plugin': plugin_menu, 'general': conf_menu, 'accs': accs}, 'types': PYLOAD.getAccountTypes()},
+ {'conf': {'plugin': plugin_menu, 'general': conf_menu, 'accs': accs},
+ 'types': PYLOAD.getAccountTypes()},
[pre_processor])
@@ -302,10 +303,7 @@ def config():
@route('/pathchooser/<path:path>')
@login_required('STATUS')
def path(file="", path=""):
- if file:
- type = "file"
- else:
- type = "folder"
+ type = "file" if file else "folder"
path = os.path.normpath(unquotepath(path))
@@ -360,10 +358,7 @@ def path(file="", path=""):
except Exception:
continue
- if os.path.isdir(join(cwd, f)):
- data['type'] = 'dir'
- else:
- data['type'] = 'file'
+ data['type'] = 'dir' if os.path.isdir(join(cwd, f)) else 'file'
if os.path.isfile(join(cwd, f)):
data['size'] = os.path.getsize(join(cwd, f))
@@ -520,11 +515,7 @@ def setup():
@route('/info')
def info():
conf = PYLOAD.getConfigDict()
-
- if hasattr(os, "uname"):
- extra = os.uname()
- else:
- extra = tuple()
+ extra = os.uname() if hasattr(os, "uname") else tuple()
data = {"python" : sys.version,
"os" : " ".join((os.name, sys.platform) + extra),
diff --git a/pyload/webui/app/utils.py b/pyload/webui/app/utils.py
index 8957f061e..2753b7feb 100644
--- a/pyload/webui/app/utils.py
+++ b/pyload/webui/app/utils.py
@@ -115,10 +115,7 @@ def login_required(perm=None):
def toDict(obj):
- ret = {}
- for att in obj.__slots__:
- ret[att] = getattr(obj, att)
- return ret
+ return {att: getattr(obj, att) for att in obj.__slots__}
class CherryPyWSGI(ServerAdapter):