[Lint] Fix pylint warnings

This commit is contained in:
bendikro 2016-10-31 19:54:10 +01:00 committed by Calum Lind
parent a438f13647
commit 59d8fc9a14
11 changed files with 25 additions and 20 deletions

View File

@ -46,7 +46,7 @@ class PluginManager(deluge.pluginmanagerbase.PluginManagerBase, component.Compon
self.stop()
def update_plugins(self):
for plugin in self.plugins.keys():
for plugin in self.plugins:
if hasattr(self.plugins[plugin], "update"):
try:
self.plugins[plugin].update()

View File

@ -1354,7 +1354,8 @@ class Torrent(object):
If the key is no longer valid, the dict will be deleted.
"""
for key in self.prev_status.keys():
# Dict will be modified so iterate over generated list
for key in list(self.prev_status):
if not self.rpcserver.is_session_valid(key):
del self.prev_status[key]

View File

@ -921,25 +921,25 @@ class TorrentManager(component.Component):
def on_set_max_connections_per_torrent(self, key, value):
"""Sets the per-torrent connection limit"""
log.debug("max_connections_per_torrent set to %s...", value)
for key in self.torrents.keys():
for key in self.torrents:
self.torrents[key].set_max_connections(value)
def on_set_max_upload_slots_per_torrent(self, key, value):
"""Sets the per-torrent upload slot limit"""
log.debug("max_upload_slots_per_torrent set to %s...", value)
for key in self.torrents.keys():
for key in self.torrents:
self.torrents[key].set_max_upload_slots(value)
def on_set_max_upload_speed_per_torrent(self, key, value):
"""Sets the per-torrent upload speed limit"""
log.debug("max_upload_speed_per_torrent set to %s...", value)
for key in self.torrents.keys():
for key in self.torrents:
self.torrents[key].set_max_upload_speed(value)
def on_set_max_download_speed_per_torrent(self, key, value):
"""Sets the per-torrent download speed limit"""
log.debug("max_download_speed_per_torrent set to %s...", value)
for key in self.torrents.keys():
for key in self.torrents:
self.torrents[key].set_max_download_speed(value)
# --- Alert handlers ---

View File

@ -73,8 +73,9 @@ class PluginManagerBase(object):
self.enable_plugin(name)
def disable_plugins(self):
# Disable all plugins that are enabled
for key in self.plugins.keys():
"""Disable all plugins that are enabled"""
# Dict will be modified so iterate over generated list
for key in list(self.plugins):
self.disable_plugin(key)
def __getitem__(self, key):

View File

@ -131,7 +131,7 @@ class Core(CorePluginBase):
for w_id, w in self.watchdirs.iteritems():
if options["abspath"] == w["abspath"] and watchdir_id != w_id:
raise Exception("Path is already being watched.")
for key in options.keys():
for key in options:
if key not in OPTIONS_AVAILABLE:
if key not in [key2 + "_toggle" for key2 in OPTIONS_AVAILABLE.iterkeys()]:
raise Exception("autoadd: Invalid options key:%s" % key)
@ -360,7 +360,7 @@ class Core(CorePluginBase):
def set_config(self, config):
"""Sets the config dictionary."""
config = self._make_unicode(config)
for key in config.keys():
for key in config:
self.config[key] = config[key]
self.config.save()
component.get("EventManager").emit(AutoaddOptionsChangedEvent())

View File

@ -46,6 +46,9 @@ DEFAULT_PREFS = {
class CoreNotifications(CustomNotifications):
def __init__(self, plugin_name=None):
CustomNotifications.__init__(self, plugin_name)
def enable(self):
CustomNotifications.enable(self)
self.register_custom_email_notification('TorrentFinishedEvent',
@ -80,7 +83,7 @@ class CoreNotifications(CustomNotifications):
def get_handled_events(self):
handled_events = []
for evt in sorted(known_events.keys()):
for evt in sorted(known_events):
if known_events[evt].__module__.startswith('deluge.event'):
if evt not in ('TorrentFinishedEvent',):
# Skip all un-handled built-in events

View File

@ -28,7 +28,7 @@ from deluge.ui.client import client
try:
import rencode
except ImportError:
import deluge.rencode as rencode
import deluge.rencode as rencode # pylint: disable=ungrouped-imports
log = logging.getLogger(__name__)

View File

@ -303,7 +303,7 @@ class ListView(object):
def get_state_field_column(self, field):
"""Returns the column number for the state field"""
for column in self.columns.keys():
for column in self.columns:
if self.columns[column].status_field is None:
continue

View File

@ -296,7 +296,7 @@ class PeersTab(Tab):
self.peers[peer["ip"]] = row
# Now we need to remove any ips that were not in status["peers"] list
for ip in set(self.peers.keys()).difference(new_ips):
for ip in set(self.peers).difference(new_ips):
self.liststore.remove(self.peers[ip])
del self.peers[ip]

View File

@ -398,7 +398,7 @@ class Preferences(component.Component):
core_widgets[self.copy_torrent_files_path_chooser] = ("path_chooser", "torrentfiles_location")
# Update the widgets accordingly
for key in core_widgets.keys():
for key in core_widgets:
modifier = core_widgets[key][0]
if isinstance(key, str):
widget = self.builder.get_object(key)
@ -431,7 +431,7 @@ class Preferences(component.Component):
widget.set_text(value, cursor_end=False, default_text=True)
if self.is_connected:
for key in core_widgets.keys():
for key in core_widgets:
if isinstance(key, str):
widget = self.builder.get_object(key)
else:
@ -671,7 +671,7 @@ class Preferences(component.Component):
dialog.run()
# GtkUI
for key in new_gtkui_config.keys():
for key in new_gtkui_config:
# The values do not match so this needs to be updated
if self.gtkui_config[key] != new_gtkui_config[key]:
self.gtkui_config[key] = new_gtkui_config[key]
@ -680,7 +680,7 @@ class Preferences(component.Component):
if client.connected():
# Only do this if we're connected to a daemon
config_to_set = {}
for key in new_core_config.keys():
for key in new_core_config:
# The values do not match so this needs to be updated
if self.core_config[key] != new_core_config[key]:
config_to_set[key] = new_core_config[key]
@ -806,7 +806,7 @@ class Preferences(component.Component):
if dep in dependents:
update_dependent_widgets(dep, depwidget.get_active() and sensitive)
for key in dependents.keys():
for key in dependents:
if widget != self.builder.get_object(key):
continue
update_dependent_widgets(key, value)

View File

@ -89,7 +89,7 @@ def create_gettext_js(js_dir):
gettext_file = os.path.join(os.path.dirname(js_dir), 'gettext.js')
with open(gettext_file, 'w') as fp:
fp.write(gettext_tpl)
for key in sorted(strings.keys()):
for key in sorted(strings):
if DEBUG:
fp.write('\n// %s\n' % ', '.join(['%s:%s' % x for x in strings[key]]))
fp.write('''GetText.add('%(key)s','${escape(_("%(key)s"))}')\n''' % locals())