summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2015-10-24 01:58:14 +0200
committerCalum Lind <calumlind+deluge@gmail.com>2015-10-30 19:39:52 +0100
commitd280fa9fbdecf3fc741e49e28281b590e2e93496 (patch)
treef836924825e75201a103b3d3e8561ba9fca8780d
parent[Lint] Cleanup code to pass PyLint Warning category (diff)
downloaddeluge-d280fa9fbdecf3fc741e49e28281b590e2e93496.tar.xz
deluge-d280fa9fbdecf3fc741e49e28281b590e2e93496.zip
[Lint] Cleanup helper scripts to pass PyLint
-rwxr-xr-xgen_web_gettext.py2
-rwxr-xr-xgenerate_pot.py4
-rwxr-xr-xminify_web_js.py6
-rwxr-xr-xmsgfmt.py6
-rw-r--r--packaging/win32/deluge-bbfreeze.py24
-rwxr-xr-xsetup.py4
-rwxr-xr-xversion.py4
7 files changed, 30 insertions, 20 deletions
diff --git a/gen_web_gettext.py b/gen_web_gettext.py
index 48535648c..066b91687 100755
--- a/gen_web_gettext.py
+++ b/gen_web_gettext.py
@@ -10,6 +10,8 @@
"""Script to parse javascript files for translation strings and generate gettext.js"""
+from __future__ import print_function
+
import os
import re
diff --git a/generate_pot.py b/generate_pot.py
index 51660f56a..b46baee77 100755
--- a/generate_pot.py
+++ b/generate_pot.py
@@ -11,6 +11,8 @@
"""Parses Python and Javascript code for translation strings to create the 'deluge.pot' template for translators"""
+from __future__ import print_function
+
import os
import re
from datetime import datetime
@@ -30,7 +32,7 @@ WEBUI_RENDER_DIR = "deluge/ui/web/render"
INFILES_LIST = "infiles.list"
POT_FILEPATH = os.path.join("deluge", "i18n", "deluge.pot")
-RE_EXC_PLUGIN_BUILD = re.compile("deluge\/plugins\/.*\/build")
+RE_EXC_PLUGIN_BUILD = re.compile("deluge\\/plugins\\/.*\\/build")
xgettext_cmd = [
"xgettext",
diff --git a/minify_web_js.py b/minify_web_js.py
index 0c8a98dde..947da3052 100755
--- a/minify_web_js.py
+++ b/minify_web_js.py
@@ -15,6 +15,8 @@ Usage: python minify_web_js.py deluge/ui/web/js/deluge-all
"""
+from __future__ import print_function
+
import fileinput
import fnmatch
import os
@@ -106,5 +108,5 @@ if __name__ == '__main__':
else:
JS_SOURCE_DIRS = [os.path.abspath(sys.argv[1])]
- for source_dir in JS_SOURCE_DIRS:
- minify_js_dir(source_dir)
+ for js_source_dir in JS_SOURCE_DIRS:
+ minify_js_dir(js_source_dir)
diff --git a/msgfmt.py b/msgfmt.py
index fc8df05e5..214327fd6 100755
--- a/msgfmt.py
+++ b/msgfmt.py
@@ -27,6 +27,7 @@ Options:
"""
import array
+import ast
import getopt
import os
import struct
@@ -51,7 +52,6 @@ def add(msgid, transtr, fuzzy):
"""
Add a non-fuzzy translation to the dictionary.
"""
- global MESSAGES
if not fuzzy and transtr and not transtr.startswith('\0'):
MESSAGES[msgid] = transtr
@@ -60,7 +60,6 @@ def generate():
"""
Return the generated output.
"""
- global MESSAGES
keys = MESSAGES.keys()
# the keys are sorted in the .mo file
keys.sort()
@@ -165,8 +164,7 @@ def make(filename, outfile):
l = l.strip()
if not l:
continue
- # XXX: Does this always follow Python escape semantics?
- l = eval(l)
+ l = ast.literal_eval(l)
if section == section_id:
msgid += l
elif section == section_str:
diff --git a/packaging/win32/deluge-bbfreeze.py b/packaging/win32/deluge-bbfreeze.py
index 1a074f1b3..d3ecaa917 100644
--- a/packaging/win32/deluge-bbfreeze.py
+++ b/packaging/win32/deluge-bbfreeze.py
@@ -11,6 +11,8 @@
# See LICENSE for more details.
#
+from __future__ import print_function
+
import glob
import os
import re
@@ -27,7 +29,7 @@ import deluge.common
class VersionInfo(object):
def __init__(self, version, internalname=None, originalfilename=None,
comments=None, company=None, description=None,
- copyright=None, trademarks=None, product=None, dll=False,
+ _copyright=None, trademarks=None, product=None, dll=False,
debug=False, verbose=True):
parts = version.split(".")
while len(parts) < 4:
@@ -38,7 +40,7 @@ class VersionInfo(object):
self.comments = comments
self.company = company
self.description = description
- self.copyright = copyright
+ self.copyright = _copyright
self.trademarks = trademarks
self.product = product
self.dll = dll
@@ -105,7 +107,7 @@ for script in glob.glob(os.path.join(python_path, "Scripts\\deluge*-script.py*")
try:
fzr.addScript(new_script, gui_only=gui_script)
script_list.append(new_script)
- except:
+ except Exception:
os.remove(script)
# Start the freezing process.
@@ -120,9 +122,9 @@ excludeDlls = ("MSIMG32.dll", "MSVCR90.dll", "MSVCP90.dll", "MSVCR120.dll",
"POWRPROF.dll", "DNSAPI.dll", "USP10.dll", "MPR.dll",
"jpeg.dll", "libfreetype-6.dll", "libpng12-0.dll", "libtiff.dll",
"SDL_image.dll", "SDL_ttf.dll")
-for dll in excludeDlls:
+for exclude_dll in excludeDlls:
try:
- os.remove(os.path.join(build_dir, dll))
+ os.remove(os.path.join(build_dir, exclude_dll))
except OSError:
pass
@@ -135,11 +137,11 @@ gtk_locale = os.path.join(gtk_root, 'share/locale')
locale_include_list = ['gtk20.mo', 'locale.alias']
-def ignored_files(adir, filenames):
+def ignored_files(adir, ignore_filenames):
return [
- filename for filename in filenames
- if not os.path.isdir(os.path.join(adir, filename))
- and filename not in locale_include_list
+ ignore_file for ignore_file in ignore_filenames
+ if not os.path.isdir(os.path.join(adir, ignore_file)) and
+ ignore_file not in locale_include_list
]
shutil.copytree(gtk_locale, os.path.join(build_dir, 'share/locale'), ignore=ignored_files)
@@ -160,7 +162,7 @@ for path_root, path in theme_include_list:
dst_dir = os.path.join(build_dir, os.path.dirname(path))
try:
os.makedirs(dst_dir)
- except:
+ except OSError:
pass
shutil.copy(full_path, dst_dir)
@@ -173,7 +175,7 @@ for script in script_list:
description="Deluge Bittorrent Client",
company="Deluge Team",
product="Deluge",
- copyright="Deluge Team")
+ _copyright="Deluge Team")
stamp(os.path.join(build_dir, script_exe), versionInfo)
# Copy version info to file for nsis script.
diff --git a/setup.py b/setup.py
index b28dbd696..fa7408b4a 100755
--- a/setup.py
+++ b/setup.py
@@ -9,6 +9,8 @@
# See LICENSE for more details.
#
+from __future__ import print_function
+
import glob
import os
import platform
@@ -91,7 +93,7 @@ class BuildTranslations(cmd.Command):
os.system('C_ALL=C ' + '%s ' * 5 % (intltool_merge, intltool_merge_opts,
po_dir, desktop_in, desktop_data))
- print('Compiling po files from %s...' % po_dir),
+ print('Compiling po files from %s...' % po_dir)
for path, names, filenames in os.walk(po_dir):
for f in filenames:
upto_date = False
diff --git a/version.py b/version.py
index 61decd5ec..bdda61653 100755
--- a/version.py
+++ b/version.py
@@ -31,11 +31,13 @@
# include RELEASE-VERSION
#
-__all__ = ("get_version")
+from __future__ import print_function
import os
from subprocess import PIPE, Popen
+__all__ = ("get_version")
+
VERSION_FILE = os.path.join(os.path.dirname(__file__), "RELEASE-VERSION")