summaryrefslogtreecommitdiffstats
path: root/pyload/webui
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-12 02:00:28 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-12 03:22:29 +0200
commit0349b81a10d2937897f30031c4dedb49aa132d8c (patch)
tree3db2827cd64888cc013e064d4e201b8a6ddbc7a9 /pyload/webui
parentMerge pull request #12 from GammaC0de/GammaC0de-fix-api (diff)
downloadpyload-0349b81a10d2937897f30031c4dedb49aa132d8c.tar.xz
'from os' -> 'import os' and so on...
Diffstat (limited to 'pyload/webui')
-rw-r--r--pyload/webui/__init__.py19
-rw-r--r--pyload/webui/app/cnl.py5
-rw-r--r--pyload/webui/app/json.py5
-rw-r--r--pyload/webui/app/pyloadweb.py50
-rw-r--r--pyload/webui/app/utils.py5
-rw-r--r--pyload/webui/filters.py13
6 files changed, 45 insertions, 52 deletions
diff --git a/pyload/webui/__init__.py b/pyload/webui/__init__.py
index 665be763a..58d60b5cc 100644
--- a/pyload/webui/__init__.py
+++ b/pyload/webui/__init__.py
@@ -1,15 +1,12 @@
# -*- coding: utf-8 -*-
# @author: RaNaN, vuolter
+import os
import sys
import pyload.utils.pylgettext as gettext
-import os
-from os.path import join, abspath, dirname, exists
-from os import makedirs
-
-THEME_DIR = abspath(join(dirname(__file__), "themes"))
-PYLOAD_DIR = abspath(join(THEME_DIR, "..", "..", ".."))
+THEME_DIR = os.path.abspath(os.path.join(dirname(__file__), "themes"))
+PYLOAD_DIR = os.path.abspath(os.path.join(THEME_DIR, "..", "..", ".."))
sys.path.append(PYLOAD_DIR)
@@ -52,13 +49,13 @@ if PREFIX:
DEBUG = config.get("general", "debug_mode") or "-d" in sys.argv or "--debug" in sys.argv
bottle.debug(DEBUG)
-cache = join("tmp", "jinja_cache")
-if not exists(cache):
- makedirs(cache)
+cache = os.path.join("tmp", "jinja_cache")
+if not os.path.exists(cache):
+ os.makedirs(cache)
bcc = FileSystemBytecodeCache(cache, '%s.cache')
-loader = FileSystemLoader([THEME_DIR, join(THEME_DIR, THEME)])
+loader = FileSystemLoader([THEME_DIR, os.path.join(THEME_DIR, THEME)])
env = Environment(loader=loader, extensions=['jinja2.ext.i18n', 'jinja2.ext.autoescape'], trim_blocks=True, auto_reload=False,
bytecode_cache=bcc)
@@ -80,7 +77,7 @@ else:
env.filters['url'] = lambda x: PREFIX + x if x.startswith("/") else x
gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
-translation = gettext.translation("django", join(PYLOAD_DIR, "locale"),
+translation = gettext.translation("django", os.path.join(PYLOAD_DIR, "locale"),
languages=[config.get("general", "language"), "en"],fallback=True)
translation.install(True)
env.install_gettext_translations(translation)
diff --git a/pyload/webui/app/cnl.py b/pyload/webui/app/cnl.py
index 635d4030c..fb64cbc5c 100644
--- a/pyload/webui/app/cnl.py
+++ b/pyload/webui/app/cnl.py
@@ -2,8 +2,9 @@
from __future__ import with_statement
-from os.path import join
+import os
import re
+
from urllib import unquote
from base64 import standard_b64decode
from binascii import unhexlify
@@ -60,7 +61,7 @@ def addcrypted():
package = request.forms.get('referer', 'ClickNLoad Package')
dlc = request.forms['crypted'].replace(" ", "+")
- dlc_path = join(DL_ROOT, package.replace("/", "").replace("\\", "").replace(":", "") + ".dlc")
+ dlc_path = os.path.join(DL_ROOT, package.replace("/", "").replace("\\", "").replace(":", "") + ".dlc")
with open(dlc_path, "wb") as dlc_file:
dlc_file.write(dlc)
diff --git a/pyload/webui/app/json.py b/pyload/webui/app/json.py
index 400eba624..24952cc34 100644
--- a/pyload/webui/app/json.py
+++ b/pyload/webui/app/json.py
@@ -2,11 +2,10 @@
from __future__ import with_statement
+import os
import shutil
import traceback
-from os.path import join
-
from bottle import route, request, HTTPError
from pyload.utils import decode, formatSize
@@ -166,7 +165,7 @@ def add_package():
if not name or name == "New Package":
name = f.name
- fpath = join(PYLOAD.getConfigValue("general", "download_folder"), "tmp_" + f.filename)
+ fpath = os.path.join(PYLOAD.getConfigValue("general", "download_folder"), "tmp_" + f.filename)
with open(fpath, 'wb') as destination:
shutil.copyfileobj(f.file, destination)
links.insert(0, fpath)
diff --git a/pyload/webui/app/pyloadweb.py b/pyload/webui/app/pyloadweb.py
index 7f2317bd1..8ce9f2f74 100644
--- a/pyload/webui/app/pyloadweb.py
+++ b/pyload/webui/app/pyloadweb.py
@@ -1,14 +1,12 @@
# -*- coding: utf-8 -*-
# @author: RaNaN
-from datetime import datetime
-from operator import itemgetter, attrgetter
-
-import time
import os
import sys
-from os import listdir
-from os.path import isdir, isfile, join, abspath
+import time
+
+from datetime import datetime
+from operator import itemgetter, attrgetter
from sys import getfilesystemencoding
from urllib import unquote
@@ -81,8 +79,8 @@ def error500(error):
@route('/<theme>/<file:re:(.+/)?[^/]+\.min\.[^/]+>')
def server_min(theme, file):
- filename = join(THEME_DIR, THEME, theme, file)
- if not isfile(filename):
+ filename = os.path.join(THEME_DIR, THEME, theme, file)
+ if not os.path.isfile(filename):
file = file.replace(".min.", ".")
if file.endswith(".js"):
return server_js(theme, file)
@@ -196,32 +194,32 @@ def collector():
def downloads():
root = PYLOAD.getConfigValue("general", "download_folder")
- if not isdir(root):
+ if not os.path.isdir(root):
return base([_('Download directory not found.')])
data = {
'folder': [],
'files': []
}
- items = listdir(fs_encode(root))
+ items = os.listdir(fs_encode(root))
for item in sorted([fs_decode(x) for x in items]):
- if isdir(fs_join(root, item)):
+ if os.path.isdir(fs_join(root, item)):
folder = {
'name': item,
'path': item,
'files': []
}
- files = listdir(fs_join(root, item))
+ files = os.listdir(fs_join(root, item))
for file in sorted([fs_decode(x) for x in files]):
try:
- if isfile(fs_join(root, item, file)):
+ if os.path.isfile(fs_join(root, item, file)):
folder['files'].append(file)
except Exception:
pass
data['folder'].append(folder)
- elif isfile(join(root, item)):
+ elif os.path.isfile(os.path.join(root, item)):
data['files'].append(item)
return render_to_response('downloads.html', {'files': data}, [pre_processor])
@@ -302,7 +300,7 @@ def config():
@route('/filechooser/<file:path>')
@route('/pathchooser/<path:path>')
@login_required('STATUS')
-def path(file="", path=""):
+def os.path(file="", path=""):
type = "file" if file else "folder"
path = os.path.normpath(unquotepath(path))
@@ -320,7 +318,7 @@ def path(file="", path=""):
cwd = os.path.abspath(path)
abs = True
else:
- cwd = relpath(path)
+ cwd = os.relpath(path)
else:
cwd = os.getcwd()
@@ -333,10 +331,10 @@ def path(file="", path=""):
parentdir = os.path.dirname(cwd)
if not abs:
if os.path.abspath(cwd) == "/":
- cwd = relpath(cwd)
+ cwd = os.relpath(cwd)
else:
- cwd = relpath(cwd) + os.path.sep
- parentdir = relpath(parentdir) + os.path.sep
+ cwd = os.relpath(cwd) + os.path.sep
+ parentdir = os.relpath(parentdir) + os.path.sep
if os.path.abspath(cwd) == "/":
parentdir = ""
@@ -351,17 +349,17 @@ def path(file="", path=""):
for f in folders:
try:
f = f.decode(getfilesystemencoding())
- data = {'name': f, 'fullpath': join(cwd, f)}
+ data = {'name': f, 'fullpath': os.path.join(cwd, f)}
data['sort'] = data['fullpath'].lower()
- data['modified'] = datetime.fromtimestamp(int(os.path.getmtime(join(cwd, f))))
+ data['modified'] = datetime.fromtimestamp(int(os.path.getmtime(os.path.join(cwd, f))))
data['ext'] = os.path.splitext(f)[1]
except Exception:
continue
- data['type'] = 'dir' if os.path.isdir(join(cwd, f)) else 'file'
+ data['type'] = 'dir' if os.path.isdir(os.path.join(cwd, f)) else 'file'
- if os.path.isfile(join(cwd, f)):
- data['size'] = os.path.getsize(join(cwd, f))
+ if os.path.isfile(os.path.join(cwd, f)):
+ data['size'] = os.path.getsize(os.path.join(cwd, f))
power = 0
while (data['size'] / 1024) > 0.3:
@@ -520,8 +518,8 @@ def info():
data = {"python" : sys.version,
"os" : " ".join((os.name, sys.platform) + extra),
"version" : PYLOAD.getServerVersion(),
- "folder" : abspath(PYLOAD_DIR), "config": abspath(""),
- "download" : abspath(conf['general']['download_folder']['value']),
+ "folder" : os.path.abspath(PYLOAD_DIR), "config": os.path.abspath(""),
+ "download" : os.path.abspath(conf['general']['download_folder']['value']),
"freespace": formatSize(PYLOAD.freeSpace()),
"remote" : conf['remote']['port']['value'],
"webif" : conf['webui']['port']['value'],
diff --git a/pyload/webui/app/utils.py b/pyload/webui/app/utils.py
index 2753b7feb..69682fe67 100644
--- a/pyload/webui/app/utils.py
+++ b/pyload/webui/app/utils.py
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
# @author: RaNaN, vuolter
-from os.path import join
+import os
from bottle import request, HTTPError, redirect, ServerAdapter
-from pyload.webui import env, THEME
-
from pyload.api import has_permission, PERMS, ROLE
+from pyload.webui import env, THEME
def render_to_response(file, args={}, proc=[]):
diff --git a/pyload/webui/filters.py b/pyload/webui/filters.py
index e11944c94..9d4d47c04 100644
--- a/pyload/webui/filters.py
+++ b/pyload/webui/filters.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
import os
-from os.path import abspath, commonprefix, join
quotechar = "::/"
@@ -11,18 +10,18 @@ except Exception:
from posixpath import curdir, sep, pardir
- def relpath(path, start=curdir):
+ def os.relpath(path, start=curdir):
"""Return a relative version of a path"""
if not path:
raise ValueError("no path specified")
- start_list = abspath(start).split(sep)
- path_list = abspath(path).split(sep)
+ start_list = os.path.abspath(start).split(sep)
+ path_list = os.path.abspath(path).split(sep)
# Work out how much of the filepath is shared by start and path.
- i = len(commonprefix([start_list, path_list]))
+ i = len(os.path.commonprefix([start_list, path_list]))
rel_list = [pardir] * (len(start_list) - i) + path_list[i:]
if not rel_list:
return curdir
- return join(*rel_list)
+ return os.path.join(*rel_list)
def quotepath(path):
@@ -52,7 +51,7 @@ def path_make_absolute(path):
def path_make_relative(path):
- p = relpath(path)
+ p = os.relpath(path)
if p[-1] == os.path.sep:
return p
else: