Skip to content

Commit

Permalink
[Lint] Cleanup helper scripts to pass PyLint
Browse files Browse the repository at this point in the history
  • Loading branch information
cas-- committed Oct 30, 2015
1 parent 807fa60 commit d280fa9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
2 changes: 2 additions & 0 deletions gen_web_gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion generate_pot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,7 +32,7 @@
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",
Expand Down
6 changes: 4 additions & 2 deletions minify_web_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"""

from __future__ import print_function

import fileinput
import fnmatch
import os
Expand Down Expand Up @@ -106,5 +108,5 @@ def minify_js_dir(source_dir):
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)
6 changes: 2 additions & 4 deletions msgfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"""

import array
import ast
import getopt
import os
import struct
Expand All @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 13 additions & 11 deletions packaging/win32/deluge-bbfreeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# See LICENSE for more details.
#

from __future__ import print_function

import glob
import os
import re
Expand All @@ -27,7 +29,7 @@
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:
Expand All @@ -38,7 +40,7 @@ def __init__(self, version, internalname=None, originalfilename=None,
self.comments = comments
self.company = company
self.description = description
self.copyright = copyright
self.copyright = _copyright
self.trademarks = trademarks
self.product = product
self.dll = dll
Expand Down Expand Up @@ -105,7 +107,7 @@ def recipe_gtk_override(mf):
try:
fzr.addScript(new_script, gui_only=gui_script)
script_list.append(new_script)
except:
except Exception:
os.remove(script)

# Start the freezing process.
Expand All @@ -120,9 +122,9 @@ def recipe_gtk_override(mf):
"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

Expand All @@ -135,11 +137,11 @@ def recipe_gtk_override(mf):
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)

Expand All @@ -160,7 +162,7 @@ def ignored_files(adir, filenames):
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)

Expand All @@ -173,7 +175,7 @@ def ignored_files(adir, filenames):
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.
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# See LICENSE for more details.
#

from __future__ import print_function

import glob
import os
import platform
Expand Down Expand Up @@ -91,7 +93,7 @@ def run(self):
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
Expand Down
4 changes: 3 additions & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down

0 comments on commit d280fa9

Please sign in to comment.