[Lint] Enable pylint 'bad-continuation' and fix issues

There is some discrepency between pep8 and pylint for line
continuation (https://github.com/PyCQA/pylint/issues/747) but
with some minor layout changes both can pass and code looks fine,
if not better in places.
This commit is contained in:
Calum Lind 2016-04-29 23:19:55 +01:00
parent 807d7a7aaf
commit 618d2f9f58
17 changed files with 89 additions and 94 deletions

View File

@ -62,8 +62,7 @@ confidence=
# #
# Arranged by category: Convention, Error, Information, Refactor, Warning. # Arranged by category: Convention, Error, Information, Refactor, Warning.
# Category per line (wrapped categories are indented) using symbolic names instead of ids. # Category per line (wrapped categories are indented) using symbolic names instead of ids.
disable=missing-docstring, invalid-name, bad-continuation, wrong-import-position, disable=missing-docstring, invalid-name, wrong-import-position, wrong-import-order,
wrong-import-order,
no-member, not-callable, no-name-in-module, no-member, not-callable, no-name-in-module,
locally-disabled, locally-disabled,
R, R,

View File

@ -1009,8 +1009,8 @@ class Torrent(object):
"save_path": lambda: self.options["download_location"], # Deprecated, use download_location "save_path": lambda: self.options["download_location"], # Deprecated, use download_location
"download_location": lambda: self.options["download_location"], "download_location": lambda: self.options["download_location"],
"seeding_time": lambda: self.status.seeding_time, "seeding_time": lambda: self.status.seeding_time,
"seeds_peers_ratio": lambda: -1.0 if self.status.num_incomplete == 0 else "seeds_peers_ratio": lambda: -1.0 if self.status.num_incomplete == 0 else ( # Use -1.0 to signify infinity
self.status.num_complete / self.status.num_incomplete, # Use -1.0 to signify infinity self.status.num_complete / self.status.num_incomplete),
"seed_rank": lambda: self.status.seed_rank, "seed_rank": lambda: self.status.seed_rank,
"state": lambda: self.state, "state": lambda: self.state,
"stop_at_ratio": lambda: self.options["stop_at_ratio"], "stop_at_ratio": lambda: self.options["stop_at_ratio"],

View File

@ -66,8 +66,7 @@ class TorrentState: # pylint: disable=old-style-class
shared=False, shared=False,
super_seeding=False, super_seeding=False,
priority=0, priority=0,
name=None name=None):
):
# Build the class atrribute list from args # Build the class atrribute list from args
for key, value in locals().items(): for key, value in locals().items():
if key == "self": if key == "self":

View File

@ -30,20 +30,22 @@ from .graph import Graph, size_formatter_scale
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
DEFAULT_CONF = {'version': 1, DEFAULT_CONF = {
'version': 1,
'colors': { 'colors': {
'bandwidth_graph': {'upload_rate': str(gtk.gdk.Color("blue")), 'bandwidth_graph': {
'upload_rate': str(gtk.gdk.Color("blue")),
'download_rate': str(gtk.gdk.Color("green")), 'download_rate': str(gtk.gdk.Color("green")),
}, },
'connections_graph': {'dht_nodes': str(gtk.gdk.Color("orange")), 'connections_graph': {
'dht_nodes': str(gtk.gdk.Color("orange")),
'dht_cache_nodes': str(gtk.gdk.Color("blue")), 'dht_cache_nodes': str(gtk.gdk.Color("blue")),
'dht_torrents': str(gtk.gdk.Color("green")), 'dht_torrents': str(gtk.gdk.Color("green")),
'num_connections': str(gtk.gdk.Color("darkred")), 'num_connections': str(gtk.gdk.Color("darkred")),
}, },
'seeds_graph': {'num_peers': str(gtk.gdk.Color("blue")), 'seeds_graph': {
}, 'num_peers': str(gtk.gdk.Color("blue")),
} }}}
}
def neat_time(column, cell, model, data): def neat_time(column, cell, model, data):

View File

@ -305,11 +305,13 @@ class FileTree2(object):
for path in directory["contents"].keys(): for path in directory["contents"].keys():
full_path = os.path.join(parent_path, path).replace("\\", "/") full_path = os.path.join(parent_path, path).replace("\\", "/")
if directory["contents"][path]["type"] == "dir": if directory["contents"][path]["type"] == "dir":
directory["contents"][path] = callback(full_path, directory["contents"][path] directory["contents"][path] = callback(
full_path, directory["contents"][path]
) or directory["contents"][path] ) or directory["contents"][path]
walk(directory["contents"][path], full_path) walk(directory["contents"][path], full_path)
else: else:
directory["contents"][path] = callback(full_path, directory["contents"][path] directory["contents"][path] = callback(
full_path, directory["contents"][path]
) or directory["contents"][path] ) or directory["contents"][path]
walk(self.tree, "") walk(self.tree, "")

View File

@ -47,8 +47,7 @@ class EventLog(component.Component):
def on_torrent_status(status): def on_torrent_status(status):
self.write("{!green!}Torrent Added: {!info!}%s ({!cyan!}%s{!info!})" % ( self.write("{!green!}Torrent Added: {!info!}%s ({!cyan!}%s{!info!})" % (
status["name"], torrent_id) status["name"], torrent_id))
)
# Write out what state the added torrent took # Write out what state the added torrent took
self.on_torrent_state_changed_event(torrent_id, status["state"]) self.on_torrent_state_changed_event(torrent_id, status["state"])

View File

@ -77,5 +77,5 @@ def add_torrent(t_file, options, success_cb, fail_cb, ress):
filename = os.path.split(f)[-1] filename = os.path.split(f)[-1]
filedump = base64.encodestring(open(f).read()) filedump = base64.encodestring(open(f).read())
client.core.add_torrent_file(filename, filedump, t_options client.core.add_torrent_file(
).addCallback(success_cb, f, ress).addErrback(fail_cb, f, ress) filename, filedump, t_options).addCallback(success_cb, f, ress).addErrback(fail_cb, f, ress)

View File

@ -186,7 +186,8 @@ DEFAULT_PREFS = {
"addtorrents_last_path": "~" "addtorrents_last_path": "~"
} }
column_pref_names = ["queue", "name", "size", "state", "progress", "seeds", column_pref_names = [
"queue", "name", "size", "state", "progress", "seeds",
"peers", "downspeed", "upspeed", "eta", "ratio", "avail", "peers", "downspeed", "upspeed", "eta", "ratio", "avail",
"added", "tracker", "savepath", "downloaded", "uploaded", "added", "tracker", "savepath", "downloaded", "uploaded",
"remaining", "owner", "downloading_time", "seeding_time", "remaining", "owner", "downloading_time", "seeding_time",
@ -330,7 +331,8 @@ class AllTorrents(BaseMode, component.Component):
("Seed Rank", str, ("seed_rank",)), ("Seed Rank", str, ("seed_rank",)),
] ]
self.__status_keys = ["name", "state", "download_payload_rate", "upload_payload_rate", self.__status_keys = [
"name", "state", "download_payload_rate", "upload_payload_rate",
"progress", "eta", "download_location", "all_time_download", "total_uploaded", "progress", "eta", "download_location", "all_time_download", "total_uploaded",
"ratio", "num_seeds", "total_seeds", "num_peers", "total_peers", "ratio", "num_seeds", "total_seeds", "num_peers", "total_peers",
"active_time", "seeding_time", "last_seen_complete", "time_added", "active_time", "seeding_time", "last_seen_complete", "time_added",
@ -347,15 +349,15 @@ class AllTorrents(BaseMode, component.Component):
# component start/update # component start/update
def start(self): def start(self):
component.get("SessionProxy").get_torrents_status(self.__status_dict, self.__status_fields component.get("SessionProxy").get_torrents_status(
).addCallback(self.set_state, False) self.__status_dict, self.__status_fields).addCallback(self.set_state, False)
def update(self): def update(self):
component.get("SessionProxy").get_torrents_status(self.__status_dict, self.__status_fields component.get("SessionProxy").get_torrents_status(
).addCallback(self.set_state, True) self.__status_dict, self.__status_fields).addCallback(self.set_state, True)
if self.__torrent_info_id: if self.__torrent_info_id:
component.get("SessionProxy").get_torrent_status(self.__torrent_info_id, self.__status_keys component.get("SessionProxy").get_torrent_status(
).addCallback(self._on_torrent_status) self.__torrent_info_id, self.__status_keys).addCallback(self._on_torrent_status)
def update_config(self): def update_config(self):
self.config = ConfigManager("console.conf", DEFAULT_PREFS) self.config = ConfigManager("console.conf", DEFAULT_PREFS)

View File

@ -80,24 +80,19 @@ class MainWindow(component.Component):
# Get the gtk builder file for the main window # Get the gtk builder file for the main window
self.main_builder.add_from_file(deluge.common.resource_filename( self.main_builder.add_from_file(deluge.common.resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "main_window.ui")) "deluge.ui.gtkui", os.path.join("glade", "main_window.ui")))
)
# The new release dialog # The new release dialog
self.main_builder.add_from_file(deluge.common.resource_filename( self.main_builder.add_from_file(deluge.common.resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "main_window.new_release.ui")) "deluge.ui.gtkui", os.path.join("glade", "main_window.new_release.ui")))
)
# The tabs # The tabs
self.main_builder.add_from_file(deluge.common.resource_filename( self.main_builder.add_from_file(deluge.common.resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "main_window.tabs.ui")) "deluge.ui.gtkui", os.path.join("glade", "main_window.tabs.ui")))
)
# The tabs file menu # The tabs file menu
self.main_builder.add_from_file(deluge.common.resource_filename( self.main_builder.add_from_file(deluge.common.resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "main_window.tabs.menu_file.ui")) "deluge.ui.gtkui", os.path.join("glade", "main_window.tabs.menu_file.ui")))
)
# The tabs peer menu # The tabs peer menu
self.main_builder.add_from_file(deluge.common.resource_filename( self.main_builder.add_from_file(deluge.common.resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "main_window.tabs.menu_peer.ui")) "deluge.ui.gtkui", os.path.join("glade", "main_window.tabs.menu_peer.ui")))
)
self.window = self.main_builder.get_object("main_window") self.window = self.main_builder.get_object("main_window")

View File

@ -791,9 +791,7 @@ class StoredValuesPopup(StoredValuesList, PathChooserPopup):
""" """
keyval = event.keyval keyval = event.keyval
state = event.state & gtk.accelerator_get_default_mod_mask() state = event.state & gtk.accelerator_get_default_mod_mask()
if (keyval == keysyms.Escape or if keyval == keysyms.Escape or (key_is_up(keyval) and state == gdk.MOD1_MASK):
(key_is_up(keyval) and
state == gdk.MOD1_MASK)):
self.popdown() self.popdown()
return True return True
return False return False

View File

@ -833,7 +833,8 @@ class Preferences(component.Component):
except Exception: except Exception:
return return
path_choosers = {"download_location_path_chooser": self.download_location_path_chooser, path_choosers = {
"download_location_path_chooser": self.download_location_path_chooser,
"move_completed_path_chooser": self.move_completed_path_chooser, "move_completed_path_chooser": self.move_completed_path_chooser,
"torrentfiles_location_path_chooser": self.copy_torrent_files_path_chooser "torrentfiles_location_path_chooser": self.copy_torrent_files_path_chooser
} }

View File

@ -31,8 +31,7 @@ class QueuedTorrents(component.Component):
self.config = ConfigManager("gtkui.conf") self.config = ConfigManager("gtkui.conf")
self.builder = gtk.Builder() self.builder = gtk.Builder()
self.builder.add_from_file(deluge.common.resource_filename( self.builder.add_from_file(deluge.common.resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "queuedtorrents.ui")) "deluge.ui.gtkui", os.path.join("glade", "queuedtorrents.ui")))
)
self.builder.get_object("chk_autoadd").set_active(self.config["autoadd_queued"]) self.builder.get_object("chk_autoadd").set_active(self.config["autoadd_queued"])
self.dialog = self.builder.get_object("queued_torrents_dialog") self.dialog = self.builder.get_object("queued_torrents_dialog")
self.dialog.set_icon(get_logo(32)) self.dialog.set_icon(get_logo(32))

View File

@ -41,8 +41,7 @@ class RemoveTorrentDialog(object):
self.builder = gtk.Builder() self.builder = gtk.Builder()
self.builder.add_from_file(deluge.common.resource_filename( self.builder.add_from_file(deluge.common.resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "remove_torrent_dialog.ui")) "deluge.ui.gtkui", os.path.join("glade", "remove_torrent_dialog.ui")))
)
self.__dialog = self.builder.get_object("remove_torrent_dialog") self.__dialog = self.builder.get_object("remove_torrent_dialog")
self.__dialog.set_transient_for(component.get("MainWindow").window) self.__dialog.set_transient_for(component.get("MainWindow").window)

View File

@ -64,8 +64,7 @@ class SystemTray(component.Component):
"""Enables the system tray icon.""" """Enables the system tray icon."""
self.builder = gtk.Builder() self.builder = gtk.Builder()
self.builder.add_from_file(deluge.common.resource_filename( self.builder.add_from_file(deluge.common.resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "tray_menu.ui")) "deluge.ui.gtkui", os.path.join("glade", "tray_menu.ui")))
)
self.builder.connect_signals({ self.builder.connect_signals({
"on_menuitem_show_deluge_activate": self.on_menuitem_show_deluge_activate, "on_menuitem_show_deluge_activate": self.on_menuitem_show_deluge_activate,

View File

@ -42,7 +42,8 @@ ICON_STATE = {
# Cache the key used to calculate the current value set for the specific cell # Cache the key used to calculate the current value set for the specific cell
# renderer. This is much cheaper than fetch the current value and test if # renderer. This is much cheaper than fetch the current value and test if
# it's equal. # it's equal.
func_last_value = {"cell_data_speed_down": None, func_last_value = {
"cell_data_speed_down": None,
"cell_data_speed_up": None, "cell_data_speed_up": None,
"cell_data_time": None, "cell_data_time": None,
"cell_data_ratio_seeds_peers": None, "cell_data_ratio_seeds_peers": None,

View File

@ -766,9 +766,9 @@ class WebApi(JSONComponent):
return client.daemon.info().addCallback(on_info) return client.daemon.info().addCallback(on_info)
else: else:
c = Client() c = Client()
return c.connect(host, port, user, password d = c.connect(host, port, user, password)
).addCallback(on_connect, c, host_id d.addCallback(on_connect, c, host_id).addErrback(on_connect_failed, host_id)
).addErrback(on_connect_failed, host_id) return d
@export @export
def start_daemon(self, port): def start_daemon(self, port):