From 0349b81a10d2937897f30031c4dedb49aa132d8c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 12 May 2015 02:00:28 +0200 Subject: 'from os' -> 'import os' and so on... --- pyload/webui/app/cnl.py | 5 +++-- pyload/webui/app/json.py | 5 ++--- pyload/webui/app/pyloadweb.py | 50 +++++++++++++++++++++---------------------- pyload/webui/app/utils.py | 5 ++--- 4 files changed, 31 insertions(+), 34 deletions(-) (limited to 'pyload/webui/app') 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('//') 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/') @route('/pathchooser/') @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=[]): -- cgit v1.2.3