Skip to content

Commit

Permalink
[Lint] Fix files to pass Flake8 v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cas-- committed Nov 17, 2016
1 parent 2657cc3 commit 36cbfa8
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 3 deletions.
1 change: 1 addition & 0 deletions deluge/__rpcapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions deluge/bencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deluge/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions deluge/configmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def get_config(self, config_file, defaults=None, file_version=1):

return self.config_files[config_file]


# Singleton functions
_configmanager = _ConfigManager()

Expand Down
2 changes: 2 additions & 0 deletions deluge/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def findCaller(self): # NOQA: N802
break
return rv


levels = {
'info': logging.INFO,
'warn': logging.WARNING,
Expand Down Expand Up @@ -310,4 +311,5 @@ def __getattribute__(self, name):
)
return getattr(logging.getLogger(logger_name), name)


LOG = _BackwardsCompatibleLOG()
2 changes: 2 additions & 0 deletions deluge/plugins/Label/deluge/plugins/label/gtkui/submenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# Deferred Translation
def _(message):
return message


NO_LABEL = _('No Label')
del _

Expand Down
8 changes: 8 additions & 0 deletions deluge/rencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -250,6 +251,7 @@ def f(x, f):
for i in range(STR_FIXED_COUNT):
decode_func[int2byte(STR_FIXED_START + i)] = make_decoder(i)


make_fixed_length_string_decoders()


Expand All @@ -265,6 +267,7 @@ def f(x, f):
for i in range(LIST_FIXED_COUNT):
decode_func[int2byte(LIST_FIXED_START + i)] = make_decoder(i)


make_fixed_length_list_decoders()


Expand All @@ -278,6 +281,7 @@ def f(x, f):
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()


Expand All @@ -293,6 +297,7 @@ def f(x, f):
for i in range(DICT_FIXED_COUNT):
decode_func[int2byte(DICT_FIXED_START + i)] = make_decoder(i)


make_fixed_length_dict_decoders()


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions deluge/scripts/deluge_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions deluge/tests/test_sessionproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def __noop__(self, *args, **kwargs):
def __getattr__(self, *args, **kwargs):
return self.__noop__


client = Client()


Expand Down
1 change: 1 addition & 0 deletions deluge/tests/twisted/plugins/delugereporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, name, module, description, longOpt, shortOpt, klass): # NOQA
self.shortOpt = shortOpt
self.klass = klass


deluge = _Reporter('Deluge reporter that suppresses Stacktrace from TODO tests',
'twisted.plugins.delugereporter',
description='Deluge Reporter',
Expand Down
1 change: 1 addition & 0 deletions deluge/ui/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,5 +784,6 @@ def auth_levels_mapping(self):
def auth_levels_mapping_reverse(self):
return self._daemon_proxy.auth_levels_mapping_reverse


# This is the object clients will use
client = Client()
1 change: 1 addition & 0 deletions deluge/ui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
def _(message):
return message


STATE_TRANSLATION = {
'All': _('All'),
'Active': _('Active'),
Expand Down
2 changes: 1 addition & 1 deletion deluge/ui/console/utils/format_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'\{\|(.*)\|\}')


Expand Down
1 change: 1 addition & 0 deletions deluge/ui/gtkui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion deluge/ui/gtkui/files_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
def _(message):
return message


TRANSLATE = {
'Do Not Download': _('Do Not Download'),
'Normal Priority': _('Normal Priority'),
'High Priority': _('High Priority'),
'Highest Priority': _('Highest Priority'),
}

del _


Expand Down
2 changes: 2 additions & 0 deletions deluge/ui/gtkui/path_combo_chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,8 +1484,10 @@ def on_set_completion_accelerator_button_clicked(widget):
'on_show_hidden_files_checkbutton_toggled': on_show_hidden_files_toggled,
}


type_register(PathChooserComboBox)


if __name__ == '__main__':
import sys
w = gtk.Window()
Expand Down
1 change: 1 addition & 0 deletions deluge/ui/gtkui/torrentview_data_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
1 change: 1 addition & 0 deletions deluge/ui/tracker_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ def icon_name_to_host(icon):
"""
return icon.rpartition('.')[0]


MIME_MAP = {
'image/gif': 'gif',
'image/jpeg': 'jpg',
Expand Down
1 change: 1 addition & 0 deletions deluge/ui/web/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __getattr__(cls, name):
else:
return Mock()


MOCK_MODULES = ['deluge.ui.gtkui.gtkui', 'deluge._libtorrent',
'libtorrent', 'psyco',
'pygtk', 'gtk', 'gobject', 'gtk.gdk', 'pango', 'cairo', 'pangocairo', 'chardet']
Expand Down
1 change: 1 addition & 0 deletions gen_web_gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions minify_web_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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']
Expand Down
5 changes: 5 additions & 0 deletions packaging/win32/deluge-bbfreeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, version, internalname=None, originalfilename=None,
self.debug = debug
self.verbose = verbose


DEBUG = False
if len(sys.argv) == 2 and sys.argv[1].lower() == 'debug':
DEBUG = True
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def windows_check():
def osx_check():
return platform.system() == 'Darwin'


desktop_data = 'deluge/ui/data/share/applications/deluge.desktop'


Expand Down Expand Up @@ -314,6 +315,7 @@ def run(self):
print('Deleting %s' % desktop_data)
os.remove(desktop_data)


cmdclass = {
'build': Build,
'build_webui': BuildWebUI,
Expand Down
1 change: 1 addition & 0 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ def get_version(prefix='', suffix=''):

return version


if __name__ == '__main__':
print(get_version(prefix='deluge-', suffix='.dev0'))

0 comments on commit 36cbfa8

Please sign in to comment.