mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-19 19:14:55 +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)
|
||||
setattr(RpcApi, obj.__name__.lower(), cobj)
|
||||
|
||||
|
||||
scan_for_methods(Core)
|
||||
scan_for_methods(Daemon)
|
||||
|
|
|
@ -55,6 +55,7 @@ def decode_dict(x, f):
|
|||
r[k], f = decode_func[x[f]](x, f)
|
||||
return (r, f + 1)
|
||||
|
||||
|
||||
decode_func = {}
|
||||
decode_func['l'] = decode_list
|
||||
decode_func['d'] = decode_dict
|
||||
|
@ -122,6 +123,7 @@ def encode_dict(x, r):
|
|||
encode_func[type(v)](v, r)
|
||||
r.append('e')
|
||||
|
||||
|
||||
encode_func = {}
|
||||
encode_func[Bencached] = encode_bencached
|
||||
encode_func[IntType] = encode_int
|
||||
|
|
|
@ -276,8 +276,8 @@ def open_url_in_browser(url):
|
|||
import webbrowser
|
||||
webbrowser.open(url)
|
||||
|
||||
# Formatting text functions
|
||||
|
||||
# Formatting text functions
|
||||
byte_txt = 'B'
|
||||
kib_txt = 'KiB'
|
||||
mib_txt = 'MiB'
|
||||
|
|
|
@ -95,6 +95,7 @@ class _ConfigManager(object):
|
|||
|
||||
return self.config_files[config_file]
|
||||
|
||||
|
||||
# Singleton functions
|
||||
_configmanager = _ConfigManager()
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ class Logging(LoggingLoggerClass):
|
|||
break
|
||||
return rv
|
||||
|
||||
|
||||
levels = {
|
||||
'info': logging.INFO,
|
||||
'warn': logging.WARNING,
|
||||
|
@ -310,4 +311,5 @@ class _BackwardsCompatibleLOG(object):
|
|||
)
|
||||
return getattr(logging.getLogger(logger_name), name)
|
||||
|
||||
|
||||
LOG = _BackwardsCompatibleLOG()
|
||||
|
|
|
@ -21,6 +21,8 @@ log = logging.getLogger(__name__)
|
|||
# Deferred Translation
|
||||
def _(message):
|
||||
return message
|
||||
|
||||
|
||||
NO_LABEL = _('No Label')
|
||||
del _
|
||||
|
||||
|
|
|
@ -214,6 +214,7 @@ def decode_false(x, f):
|
|||
def decode_none(x, f):
|
||||
return (None, f + 1)
|
||||
|
||||
|
||||
decode_func = {}
|
||||
decode_func[b'0'] = 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):
|
||||
decode_func[int2byte(STR_FIXED_START + i)] = make_decoder(i)
|
||||
|
||||
|
||||
make_fixed_length_string_decoders()
|
||||
|
||||
|
||||
|
@ -265,6 +267,7 @@ def make_fixed_length_list_decoders():
|
|||
for i in range(LIST_FIXED_COUNT):
|
||||
decode_func[int2byte(LIST_FIXED_START + i)] = make_decoder(i)
|
||||
|
||||
|
||||
make_fixed_length_list_decoders()
|
||||
|
||||
|
||||
|
@ -278,6 +281,7 @@ def make_fixed_length_int_decoders():
|
|||
for i in range(INT_NEG_FIXED_COUNT):
|
||||
decode_func[int2byte(INT_NEG_FIXED_START + i)] = make_decoder(-1 - i)
|
||||
|
||||
|
||||
make_fixed_length_int_decoders()
|
||||
|
||||
|
||||
|
@ -293,6 +297,7 @@ def make_fixed_length_dict_decoders():
|
|||
for i in range(DICT_FIXED_COUNT):
|
||||
decode_func[int2byte(DICT_FIXED_START + i)] = make_decoder(i)
|
||||
|
||||
|
||||
make_fixed_length_dict_decoders()
|
||||
|
||||
|
||||
|
@ -386,6 +391,7 @@ def encode_dict(x, r):
|
|||
encode_func[type(v)](v, r)
|
||||
r.append(CHR_TERM)
|
||||
|
||||
|
||||
encode_func = {}
|
||||
encode_func[int] = 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 abs(loads(dumps(1.1, 64)) - 1.1) < 1e-12
|
||||
assert loads(dumps('Hello World!!'), decode_utf8=True)
|
||||
|
||||
|
||||
try:
|
||||
import psyco
|
||||
psyco.bind(dumps)
|
||||
|
|
|
@ -26,6 +26,7 @@ def is_float_digit(string):
|
|||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
# set up command-line options
|
||||
parser = OptionParser()
|
||||
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):
|
||||
return self.__noop__
|
||||
|
||||
|
||||
client = Client()
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ class _Reporter(object):
|
|||
self.shortOpt = shortOpt
|
||||
self.klass = klass
|
||||
|
||||
|
||||
deluge = _Reporter('Deluge reporter that suppresses Stacktrace from TODO tests',
|
||||
'twisted.plugins.delugereporter',
|
||||
description='Deluge Reporter',
|
||||
|
|
|
@ -784,5 +784,6 @@ class Client(object):
|
|||
def auth_levels_mapping_reverse(self):
|
||||
return self._daemon_proxy.auth_levels_mapping_reverse
|
||||
|
||||
|
||||
# This is the object clients will use
|
||||
client = Client()
|
||||
|
|
|
@ -32,6 +32,7 @@ log = logging.getLogger(__name__)
|
|||
def _(message):
|
||||
return message
|
||||
|
||||
|
||||
STATE_TRANSLATION = {
|
||||
'All': _('All'),
|
||||
'Active': _('Active'),
|
||||
|
|
|
@ -121,8 +121,8 @@ def format_column(col, lim):
|
|||
def format_row(row, column_widths):
|
||||
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'\{\|(.*)\|\}')
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ def get_pixbuf(filename):
|
|||
log.warning(ex)
|
||||
return create_blank_pixbuf()
|
||||
|
||||
|
||||
# Status icons.. Create them from file only once to avoid constantly re-creating them.
|
||||
icon_downloading = get_pixbuf('downloading16.png')
|
||||
icon_seeding = get_pixbuf('seeding16.png')
|
||||
|
|
|
@ -31,13 +31,13 @@ log = logging.getLogger(__name__)
|
|||
def _(message):
|
||||
return message
|
||||
|
||||
|
||||
TRANSLATE = {
|
||||
'Do Not Download': _('Do Not Download'),
|
||||
'Normal Priority': _('Normal Priority'),
|
||||
'High Priority': _('High Priority'),
|
||||
'Highest Priority': _('Highest Priority'),
|
||||
}
|
||||
|
||||
del _
|
||||
|
||||
|
||||
|
|
|
@ -1484,8 +1484,10 @@ class PathChooserComboBox(gtk.HBox, StoredValuesPopup, GObject):
|
|||
'on_show_hidden_files_checkbutton_toggled': on_show_hidden_files_toggled,
|
||||
}
|
||||
|
||||
|
||||
type_register(PathChooserComboBox)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
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 ''
|
||||
cell.set_property('text', date_str)
|
||||
|
||||
|
||||
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')
|
||||
|
||||
|
|
|
@ -562,6 +562,7 @@ def icon_name_to_host(icon):
|
|||
"""
|
||||
return icon.rpartition('.')[0]
|
||||
|
||||
|
||||
MIME_MAP = {
|
||||
'image/gif': 'gif',
|
||||
'image/jpeg': 'jpg',
|
||||
|
|
|
@ -36,6 +36,7 @@ def compress(contents, request):
|
|||
contents += compress_zlib.flush()
|
||||
return contents
|
||||
|
||||
|
||||
try:
|
||||
# This is beeing done like this in order to allow tests to use the above
|
||||
# `compress` without requiring Mako to be instaled
|
||||
|
|
|
@ -53,6 +53,7 @@ class Mock(object):
|
|||
else:
|
||||
return Mock()
|
||||
|
||||
|
||||
MOCK_MODULES = ['deluge.ui.gtkui.gtkui', 'deluge._libtorrent',
|
||||
'libtorrent', 'psyco',
|
||||
'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())
|
||||
return gettext_file
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
gettext_fname = create_gettext_js(WEBUI_JS_DIR)
|
||||
print('Created: %s' % gettext_fname)
|
||||
|
|
|
@ -31,6 +31,7 @@ def module_exists(module_name):
|
|||
else:
|
||||
return True
|
||||
|
||||
|
||||
# Imports sorted by resulting file size.
|
||||
if module_exists('closure'):
|
||||
def minify_closure(file_in, file_out):
|
||||
|
@ -109,6 +110,7 @@ def minify_js_dir(source_dir):
|
|||
else:
|
||||
print('Error minifying %s' % source_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 2:
|
||||
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.verbose = verbose
|
||||
|
||||
|
||||
DEBUG = False
|
||||
if len(sys.argv) == 2 and sys.argv[1].lower() == 'debug':
|
||||
DEBUG = True
|
||||
|
@ -79,6 +80,8 @@ def recipe_gtk_override(mf):
|
|||
# Override bbfreeze function so that it includes all gtk libraries
|
||||
# in the installer so users don't require a separate GTK+ installation.
|
||||
return True
|
||||
|
||||
|
||||
bbfreeze.recipes.recipe_gtk_and_friends = recipe_gtk_override
|
||||
|
||||
# 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
|
||||
ignore_file not in locale_include_list
|
||||
]
|
||||
|
||||
|
||||
shutil.copytree(gtk_locale, os.path.join(build_dir, 'share/locale'), ignore=ignored_files)
|
||||
|
||||
# Copy gtk theme files.
|
||||
|
|
2
setup.py
2
setup.py
|
@ -40,6 +40,7 @@ def windows_check():
|
|||
def osx_check():
|
||||
return platform.system() == 'Darwin'
|
||||
|
||||
|
||||
desktop_data = 'deluge/ui/data/share/applications/deluge.desktop'
|
||||
|
||||
|
||||
|
@ -314,6 +315,7 @@ class Clean(_clean):
|
|||
print('Deleting %s' % desktop_data)
|
||||
os.remove(desktop_data)
|
||||
|
||||
|
||||
cmdclass = {
|
||||
'build': Build,
|
||||
'build_webui': BuildWebUI,
|
||||
|
|
|
@ -73,5 +73,6 @@ def get_version(prefix='', suffix=''):
|
|||
|
||||
return version
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(get_version(prefix='deluge-', suffix='.dev0'))
|
||||
|
|
Loading…
Add table
Reference in a new issue