mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-06 08:28:39 +00:00
[Lint] Fix files to pass Flake8 v3.2.0
This commit is contained in:
parent
2657cc3921
commit
36cbfa8c61
25 changed files with 42 additions and 3 deletions
|
@ -28,5 +28,6 @@ def scan_for_methods(obj):
|
||||||
cobj = classobj(obj.__name__.lower(), (object,), methods)
|
cobj = classobj(obj.__name__.lower(), (object,), methods)
|
||||||
setattr(RpcApi, obj.__name__.lower(), cobj)
|
setattr(RpcApi, obj.__name__.lower(), cobj)
|
||||||
|
|
||||||
|
|
||||||
scan_for_methods(Core)
|
scan_for_methods(Core)
|
||||||
scan_for_methods(Daemon)
|
scan_for_methods(Daemon)
|
||||||
|
|
|
@ -55,6 +55,7 @@ def decode_dict(x, f):
|
||||||
r[k], f = decode_func[x[f]](x, f)
|
r[k], f = decode_func[x[f]](x, f)
|
||||||
return (r, f + 1)
|
return (r, f + 1)
|
||||||
|
|
||||||
|
|
||||||
decode_func = {}
|
decode_func = {}
|
||||||
decode_func['l'] = decode_list
|
decode_func['l'] = decode_list
|
||||||
decode_func['d'] = decode_dict
|
decode_func['d'] = decode_dict
|
||||||
|
@ -122,6 +123,7 @@ def encode_dict(x, r):
|
||||||
encode_func[type(v)](v, r)
|
encode_func[type(v)](v, r)
|
||||||
r.append('e')
|
r.append('e')
|
||||||
|
|
||||||
|
|
||||||
encode_func = {}
|
encode_func = {}
|
||||||
encode_func[Bencached] = encode_bencached
|
encode_func[Bencached] = encode_bencached
|
||||||
encode_func[IntType] = encode_int
|
encode_func[IntType] = encode_int
|
||||||
|
|
|
@ -276,8 +276,8 @@ def open_url_in_browser(url):
|
||||||
import webbrowser
|
import webbrowser
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
|
|
||||||
# Formatting text functions
|
|
||||||
|
|
||||||
|
# Formatting text functions
|
||||||
byte_txt = 'B'
|
byte_txt = 'B'
|
||||||
kib_txt = 'KiB'
|
kib_txt = 'KiB'
|
||||||
mib_txt = 'MiB'
|
mib_txt = 'MiB'
|
||||||
|
|
|
@ -95,6 +95,7 @@ class _ConfigManager(object):
|
||||||
|
|
||||||
return self.config_files[config_file]
|
return self.config_files[config_file]
|
||||||
|
|
||||||
|
|
||||||
# Singleton functions
|
# Singleton functions
|
||||||
_configmanager = _ConfigManager()
|
_configmanager = _ConfigManager()
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ class Logging(LoggingLoggerClass):
|
||||||
break
|
break
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
|
||||||
levels = {
|
levels = {
|
||||||
'info': logging.INFO,
|
'info': logging.INFO,
|
||||||
'warn': logging.WARNING,
|
'warn': logging.WARNING,
|
||||||
|
@ -310,4 +311,5 @@ class _BackwardsCompatibleLOG(object):
|
||||||
)
|
)
|
||||||
return getattr(logging.getLogger(logger_name), name)
|
return getattr(logging.getLogger(logger_name), name)
|
||||||
|
|
||||||
|
|
||||||
LOG = _BackwardsCompatibleLOG()
|
LOG = _BackwardsCompatibleLOG()
|
||||||
|
|
|
@ -21,6 +21,8 @@ log = logging.getLogger(__name__)
|
||||||
# Deferred Translation
|
# Deferred Translation
|
||||||
def _(message):
|
def _(message):
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
NO_LABEL = _('No Label')
|
NO_LABEL = _('No Label')
|
||||||
del _
|
del _
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,7 @@ def decode_false(x, f):
|
||||||
def decode_none(x, f):
|
def decode_none(x, f):
|
||||||
return (None, f + 1)
|
return (None, f + 1)
|
||||||
|
|
||||||
|
|
||||||
decode_func = {}
|
decode_func = {}
|
||||||
decode_func[b'0'] = decode_string
|
decode_func[b'0'] = decode_string
|
||||||
decode_func[b'1'] = decode_string
|
decode_func[b'1'] = decode_string
|
||||||
|
@ -250,6 +251,7 @@ def make_fixed_length_string_decoders():
|
||||||
for i in range(STR_FIXED_COUNT):
|
for i in range(STR_FIXED_COUNT):
|
||||||
decode_func[int2byte(STR_FIXED_START + i)] = make_decoder(i)
|
decode_func[int2byte(STR_FIXED_START + i)] = make_decoder(i)
|
||||||
|
|
||||||
|
|
||||||
make_fixed_length_string_decoders()
|
make_fixed_length_string_decoders()
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,6 +267,7 @@ def make_fixed_length_list_decoders():
|
||||||
for i in range(LIST_FIXED_COUNT):
|
for i in range(LIST_FIXED_COUNT):
|
||||||
decode_func[int2byte(LIST_FIXED_START + i)] = make_decoder(i)
|
decode_func[int2byte(LIST_FIXED_START + i)] = make_decoder(i)
|
||||||
|
|
||||||
|
|
||||||
make_fixed_length_list_decoders()
|
make_fixed_length_list_decoders()
|
||||||
|
|
||||||
|
|
||||||
|
@ -278,6 +281,7 @@ def make_fixed_length_int_decoders():
|
||||||
for i in range(INT_NEG_FIXED_COUNT):
|
for i in range(INT_NEG_FIXED_COUNT):
|
||||||
decode_func[int2byte(INT_NEG_FIXED_START + i)] = make_decoder(-1 - i)
|
decode_func[int2byte(INT_NEG_FIXED_START + i)] = make_decoder(-1 - i)
|
||||||
|
|
||||||
|
|
||||||
make_fixed_length_int_decoders()
|
make_fixed_length_int_decoders()
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,6 +297,7 @@ def make_fixed_length_dict_decoders():
|
||||||
for i in range(DICT_FIXED_COUNT):
|
for i in range(DICT_FIXED_COUNT):
|
||||||
decode_func[int2byte(DICT_FIXED_START + i)] = make_decoder(i)
|
decode_func[int2byte(DICT_FIXED_START + i)] = make_decoder(i)
|
||||||
|
|
||||||
|
|
||||||
make_fixed_length_dict_decoders()
|
make_fixed_length_dict_decoders()
|
||||||
|
|
||||||
|
|
||||||
|
@ -386,6 +391,7 @@ def encode_dict(x, r):
|
||||||
encode_func[type(v)](v, r)
|
encode_func[type(v)](v, r)
|
||||||
r.append(CHR_TERM)
|
r.append(CHR_TERM)
|
||||||
|
|
||||||
|
|
||||||
encode_func = {}
|
encode_func = {}
|
||||||
encode_func[int] = encode_int
|
encode_func[int] = encode_int
|
||||||
encode_func[long] = encode_int
|
encode_func[long] = encode_int
|
||||||
|
@ -448,6 +454,8 @@ def test():
|
||||||
assert 1e-10 < abs(loads(dumps(1.1, 32)) - 1.1) < 1e-6
|
assert 1e-10 < abs(loads(dumps(1.1, 32)) - 1.1) < 1e-6
|
||||||
assert abs(loads(dumps(1.1, 64)) - 1.1) < 1e-12
|
assert abs(loads(dumps(1.1, 64)) - 1.1) < 1e-12
|
||||||
assert loads(dumps('Hello World!!'), decode_utf8=True)
|
assert loads(dumps('Hello World!!'), decode_utf8=True)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import psyco
|
import psyco
|
||||||
psyco.bind(dumps)
|
psyco.bind(dumps)
|
||||||
|
|
|
@ -26,6 +26,7 @@ def is_float_digit(string):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# set up command-line options
|
# set up command-line options
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option('--port', help='port for deluge backend host (default: 58846)', default='58846', dest='port')
|
parser.add_option('--port', help='port for deluge backend host (default: 58846)', default='58846', dest='port')
|
||||||
|
|
|
@ -94,6 +94,7 @@ class Client(object):
|
||||||
def __getattr__(self, *args, **kwargs):
|
def __getattr__(self, *args, **kwargs):
|
||||||
return self.__noop__
|
return self.__noop__
|
||||||
|
|
||||||
|
|
||||||
client = Client()
|
client = Client()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ class _Reporter(object):
|
||||||
self.shortOpt = shortOpt
|
self.shortOpt = shortOpt
|
||||||
self.klass = klass
|
self.klass = klass
|
||||||
|
|
||||||
|
|
||||||
deluge = _Reporter('Deluge reporter that suppresses Stacktrace from TODO tests',
|
deluge = _Reporter('Deluge reporter that suppresses Stacktrace from TODO tests',
|
||||||
'twisted.plugins.delugereporter',
|
'twisted.plugins.delugereporter',
|
||||||
description='Deluge Reporter',
|
description='Deluge Reporter',
|
||||||
|
|
|
@ -784,5 +784,6 @@ class Client(object):
|
||||||
def auth_levels_mapping_reverse(self):
|
def auth_levels_mapping_reverse(self):
|
||||||
return self._daemon_proxy.auth_levels_mapping_reverse
|
return self._daemon_proxy.auth_levels_mapping_reverse
|
||||||
|
|
||||||
|
|
||||||
# This is the object clients will use
|
# This is the object clients will use
|
||||||
client = Client()
|
client = Client()
|
||||||
|
|
|
@ -32,6 +32,7 @@ log = logging.getLogger(__name__)
|
||||||
def _(message):
|
def _(message):
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
STATE_TRANSLATION = {
|
STATE_TRANSLATION = {
|
||||||
'All': _('All'),
|
'All': _('All'),
|
||||||
'Active': _('Active'),
|
'Active': _('Active'),
|
||||||
|
|
|
@ -121,8 +121,8 @@ def format_column(col, lim):
|
||||||
def format_row(row, column_widths):
|
def format_row(row, column_widths):
|
||||||
return ''.join([format_column(row[i], column_widths[i]) for i in range(0, len(row))])
|
return ''.join([format_column(row[i], column_widths[i]) for i in range(0, len(row))])
|
||||||
|
|
||||||
_strip_re = re.compile('\\{!.*?!\\}')
|
|
||||||
|
|
||||||
|
_strip_re = re.compile('\\{!.*?!\\}')
|
||||||
_format_code = re.compile(r'\{\|(.*)\|\}')
|
_format_code = re.compile(r'\{\|(.*)\|\}')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ def get_pixbuf(filename):
|
||||||
log.warning(ex)
|
log.warning(ex)
|
||||||
return create_blank_pixbuf()
|
return create_blank_pixbuf()
|
||||||
|
|
||||||
|
|
||||||
# Status icons.. Create them from file only once to avoid constantly re-creating them.
|
# Status icons.. Create them from file only once to avoid constantly re-creating them.
|
||||||
icon_downloading = get_pixbuf('downloading16.png')
|
icon_downloading = get_pixbuf('downloading16.png')
|
||||||
icon_seeding = get_pixbuf('seeding16.png')
|
icon_seeding = get_pixbuf('seeding16.png')
|
||||||
|
|
|
@ -31,13 +31,13 @@ log = logging.getLogger(__name__)
|
||||||
def _(message):
|
def _(message):
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
TRANSLATE = {
|
TRANSLATE = {
|
||||||
'Do Not Download': _('Do Not Download'),
|
'Do Not Download': _('Do Not Download'),
|
||||||
'Normal Priority': _('Normal Priority'),
|
'Normal Priority': _('Normal Priority'),
|
||||||
'High Priority': _('High Priority'),
|
'High Priority': _('High Priority'),
|
||||||
'Highest Priority': _('Highest Priority'),
|
'Highest Priority': _('Highest Priority'),
|
||||||
}
|
}
|
||||||
|
|
||||||
del _
|
del _
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1484,8 +1484,10 @@ class PathChooserComboBox(gtk.HBox, StoredValuesPopup, GObject):
|
||||||
'on_show_hidden_files_checkbutton_toggled': on_show_hidden_files_toggled,
|
'on_show_hidden_files_checkbutton_toggled': on_show_hidden_files_toggled,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type_register(PathChooserComboBox)
|
type_register(PathChooserComboBox)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
w = gtk.Window()
|
w = gtk.Window()
|
||||||
|
|
|
@ -263,6 +263,7 @@ def cell_data_date(column, cell, model, row, data, key):
|
||||||
date_str = common.fdate(date, date_only=True) if date > 0 else ''
|
date_str = common.fdate(date, date_only=True) if date > 0 else ''
|
||||||
cell.set_property('text', date_str)
|
cell.set_property('text', date_str)
|
||||||
|
|
||||||
|
|
||||||
cell_data_date_added = partial(cell_data_date, key='cell_data_date_added')
|
cell_data_date_added = partial(cell_data_date, key='cell_data_date_added')
|
||||||
cell_data_date_completed = partial(cell_data_date, key='cell_data_date_completed')
|
cell_data_date_completed = partial(cell_data_date, key='cell_data_date_completed')
|
||||||
|
|
||||||
|
|
|
@ -562,6 +562,7 @@ def icon_name_to_host(icon):
|
||||||
"""
|
"""
|
||||||
return icon.rpartition('.')[0]
|
return icon.rpartition('.')[0]
|
||||||
|
|
||||||
|
|
||||||
MIME_MAP = {
|
MIME_MAP = {
|
||||||
'image/gif': 'gif',
|
'image/gif': 'gif',
|
||||||
'image/jpeg': 'jpg',
|
'image/jpeg': 'jpg',
|
||||||
|
|
|
@ -36,6 +36,7 @@ def compress(contents, request):
|
||||||
contents += compress_zlib.flush()
|
contents += compress_zlib.flush()
|
||||||
return contents
|
return contents
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# This is beeing done like this in order to allow tests to use the above
|
# This is beeing done like this in order to allow tests to use the above
|
||||||
# `compress` without requiring Mako to be instaled
|
# `compress` without requiring Mako to be instaled
|
||||||
|
|
|
@ -53,6 +53,7 @@ class Mock(object):
|
||||||
else:
|
else:
|
||||||
return Mock()
|
return Mock()
|
||||||
|
|
||||||
|
|
||||||
MOCK_MODULES = ['deluge.ui.gtkui.gtkui', 'deluge._libtorrent',
|
MOCK_MODULES = ['deluge.ui.gtkui.gtkui', 'deluge._libtorrent',
|
||||||
'libtorrent', 'psyco',
|
'libtorrent', 'psyco',
|
||||||
'pygtk', 'gtk', 'gobject', 'gtk.gdk', 'pango', 'cairo', 'pangocairo', 'chardet']
|
'pygtk', 'gtk', 'gobject', 'gtk.gdk', 'pango', 'cairo', 'pangocairo', 'chardet']
|
||||||
|
|
|
@ -95,6 +95,7 @@ def create_gettext_js(js_dir):
|
||||||
fp.write('''GetText.add('%(key)s','${escape(_("%(key)s"))}')\n''' % locals())
|
fp.write('''GetText.add('%(key)s','${escape(_("%(key)s"))}')\n''' % locals())
|
||||||
return gettext_file
|
return gettext_file
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
gettext_fname = create_gettext_js(WEBUI_JS_DIR)
|
gettext_fname = create_gettext_js(WEBUI_JS_DIR)
|
||||||
print('Created: %s' % gettext_fname)
|
print('Created: %s' % gettext_fname)
|
||||||
|
|
|
@ -31,6 +31,7 @@ def module_exists(module_name):
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
# Imports sorted by resulting file size.
|
# Imports sorted by resulting file size.
|
||||||
if module_exists('closure'):
|
if module_exists('closure'):
|
||||||
def minify_closure(file_in, file_out):
|
def minify_closure(file_in, file_out):
|
||||||
|
@ -109,6 +110,7 @@ def minify_js_dir(source_dir):
|
||||||
else:
|
else:
|
||||||
print('Error minifying %s' % source_dir)
|
print('Error minifying %s' % source_dir)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
JS_SOURCE_DIRS = ['deluge/ui/web/js/deluge-all', 'deluge/ui/web/js/extjs/ext-extensions']
|
JS_SOURCE_DIRS = ['deluge/ui/web/js/deluge-all', 'deluge/ui/web/js/extjs/ext-extensions']
|
||||||
|
|
|
@ -47,6 +47,7 @@ class VersionInfo(object):
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
|
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
if len(sys.argv) == 2 and sys.argv[1].lower() == 'debug':
|
if len(sys.argv) == 2 and sys.argv[1].lower() == 'debug':
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
@ -79,6 +80,8 @@ def recipe_gtk_override(mf):
|
||||||
# Override bbfreeze function so that it includes all gtk libraries
|
# Override bbfreeze function so that it includes all gtk libraries
|
||||||
# in the installer so users don't require a separate GTK+ installation.
|
# in the installer so users don't require a separate GTK+ installation.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
bbfreeze.recipes.recipe_gtk_and_friends = recipe_gtk_override
|
bbfreeze.recipes.recipe_gtk_and_friends = recipe_gtk_override
|
||||||
|
|
||||||
# Workaround for "ImportError: The 'packaging' package is required" with setuptools > 18.8.
|
# Workaround for "ImportError: The 'packaging' package is required" with setuptools > 18.8.
|
||||||
|
@ -147,6 +150,8 @@ def ignored_files(adir, ignore_filenames):
|
||||||
if not os.path.isdir(os.path.join(adir, ignore_file)) and
|
if not os.path.isdir(os.path.join(adir, ignore_file)) and
|
||||||
ignore_file not in locale_include_list
|
ignore_file not in locale_include_list
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
shutil.copytree(gtk_locale, os.path.join(build_dir, 'share/locale'), ignore=ignored_files)
|
shutil.copytree(gtk_locale, os.path.join(build_dir, 'share/locale'), ignore=ignored_files)
|
||||||
|
|
||||||
# Copy gtk theme files.
|
# Copy gtk theme files.
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -40,6 +40,7 @@ def windows_check():
|
||||||
def osx_check():
|
def osx_check():
|
||||||
return platform.system() == 'Darwin'
|
return platform.system() == 'Darwin'
|
||||||
|
|
||||||
|
|
||||||
desktop_data = 'deluge/ui/data/share/applications/deluge.desktop'
|
desktop_data = 'deluge/ui/data/share/applications/deluge.desktop'
|
||||||
|
|
||||||
|
|
||||||
|
@ -314,6 +315,7 @@ class Clean(_clean):
|
||||||
print('Deleting %s' % desktop_data)
|
print('Deleting %s' % desktop_data)
|
||||||
os.remove(desktop_data)
|
os.remove(desktop_data)
|
||||||
|
|
||||||
|
|
||||||
cmdclass = {
|
cmdclass = {
|
||||||
'build': Build,
|
'build': Build,
|
||||||
'build_webui': BuildWebUI,
|
'build_webui': BuildWebUI,
|
||||||
|
|
|
@ -73,5 +73,6 @@ def get_version(prefix='', suffix=''):
|
||||||
|
|
||||||
return version
|
return version
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(get_version(prefix='deluge-', suffix='.dev0'))
|
print(get_version(prefix='deluge-', suffix='.dev0'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue