diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2017-03-16 22:39:57 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2017-03-17 00:20:56 +0100 |
commit | af7e83bc76dc2db837ebcabba612dbccc9aac9e7 (patch) | |
tree | 025fbb6f57ca6f3513d218e59c78095abec729c0 | |
parent | Add python 3 section to tox (diff) | |
download | deluge-af7e83bc76dc2db837ebcabba612dbccc9aac9e7.tar.xz deluge-af7e83bc76dc2db837ebcabba612dbccc9aac9e7.zip |
Replace/remove usage of dict.keys()
38 files changed, 74 insertions, 78 deletions
diff --git a/deluge/component.py b/deluge/component.py index 882f3c2fa..de94e021d 100644 --- a/deluge/component.py +++ b/deluge/component.py @@ -308,7 +308,7 @@ class ComponentRegistry(object): """ # Start all the components if names is empty if not names: - names = self.components.keys() + names = list(self.components) elif isinstance(names, str if not PY2 else basestring): names = [names] @@ -342,7 +342,7 @@ class ComponentRegistry(object): """ if not names: - names = self.components.keys() + names = list(self.components) elif isinstance(names, str if not PY2 else basestring): names = [names] @@ -380,7 +380,7 @@ class ComponentRegistry(object): """ if not names: - names = self.components.keys() + names = list(self.components) elif isinstance(names, str if not PY2 else basestring): names = [names] @@ -406,7 +406,7 @@ class ComponentRegistry(object): """ if not names: - names = self.components.keys() + names = list(self.components) elif isinstance(names, str if not PY2 else basestring): names = [names] @@ -431,7 +431,7 @@ class ComponentRegistry(object): def on_stopped(result): return DeferredList([comp._component_shutdown() for comp in self.components.values()]) - return self.stop(list(self.components.keys())).addCallback(on_stopped) + return self.stop(list(self.components)).addCallback(on_stopped) def update(self): """Update all Components that are in a Started state.""" diff --git a/deluge/core/filtermanager.py b/deluge/core/filtermanager.py index b2ade1abe..afced7c14 100644 --- a/deluge/core/filtermanager.py +++ b/deluge/core/filtermanager.py @@ -188,7 +188,7 @@ class FilterManager(component.Component): for use in sidebar. """ torrent_ids = self.torrents.get_torrent_list() - tree_keys = list(self.tree_fields.keys()) + tree_keys = list(self.tree_fields) if hide_cat: for cat in hide_cat: tree_keys.remove(cat) diff --git a/deluge/core/pluginmanager.py b/deluge/core/pluginmanager.py index 0d528d109..a67e92b4b 100644 --- a/deluge/core/pluginmanager.py +++ b/deluge/core/pluginmanager.py @@ -83,7 +83,7 @@ class PluginManager(deluge.pluginmanagerbase.PluginManagerBase, component.Compon """Return the value of status fields for the selected torrent_id.""" status = {} if len(fields) == 0: - fields = self.status_fields.keys() + fields = list(self.status_fields) for field in fields: try: status[field] = self.status_fields[field](torrent_id) diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py index 83123d83c..bb192a3fb 100644 --- a/deluge/core/rpcserver.py +++ b/deluge/core/rpcserver.py @@ -437,7 +437,7 @@ class RPCServer(component.Component): :returns: the exported methods :rtype: list """ - return list(self.factory.methods.keys()) + return list(self.factory.methods) def get_session_id(self): """ diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 27a620e34..ac9e83172 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -924,7 +924,7 @@ class Torrent(object): self.update_status(self.handle.status()) if all_keys: - keys = self.status_funcs + keys = list(self.status_funcs) status_dict = {} diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 14afe087b..b4b76cdaf 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -262,7 +262,7 @@ class TorrentManager(component.Component): list: A list of torrent_ids. """ - torrent_ids = list(self.torrents.keys()) + torrent_ids = list(self.torrents) if component.get('RPCServer').get_session_auth_level() == AUTH_LEVEL_ADMIN: return torrent_ids @@ -1270,7 +1270,7 @@ class TorrentManager(component.Component): if self.torrents: for torrent_id in torrent_ids: if torrent_id in self.torrents: - status_keys = list(self.torrents[torrent_id].status_funcs.keys()) + status_keys = list(self.torrents[torrent_id].status_funcs) leftover_keys = list(set(keys) - set(status_keys)) torrent_keys = list(set(keys) - set(leftover_keys)) return torrent_keys, leftover_keys diff --git a/deluge/pluginmanagerbase.py b/deluge/pluginmanagerbase.py index ae8488415..bdaab5bae 100644 --- a/deluge/pluginmanagerbase.py +++ b/deluge/pluginmanagerbase.py @@ -88,7 +88,7 @@ class PluginManagerBase(object): def get_enabled_plugins(self): """Returns a list of enabled plugins""" - return list(self.plugins.keys()) + return list(self.plugins) def scan_for_plugins(self): """Scans for available plugins""" @@ -245,14 +245,14 @@ class PluginManagerBase(object): for line in self.pkg_env[name][0].get_metadata('PKG-INFO').splitlines(): if not line: continue - if line[0] in ' \t' and (len(line.split(':', 1)) == 1 or line.split(':', 1)[0] not in list(info.keys())): + if line[0] in ' \t' and (len(line.split(':', 1)) == 1 or line.split(':', 1)[0] not in info): # This is a continuation cont_lines.append(line.strip()) else: if cont_lines: info[last_header] = '\n'.join(cont_lines).strip() cont_lines = [] - if line.split(':', 1)[0] in list(info.keys()): + if line.split(':', 1)[0] in info: last_header = line.split(':', 1)[0] info[last_header] = line.split(':', 1)[1].strip() return info diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py index e29f589b5..9ec9e2568 100644 --- a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py +++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py @@ -388,7 +388,7 @@ class Core(CorePluginBase): watchdirs[watchdir_id] = watchdir log.debug('Current logged in user %s is not an ADMIN, send only ' - 'his watchdirs: %s', session_user, list(watchdirs.keys())) + 'their watchdirs: %s', session_user, list(watchdirs)) return watchdirs def _make_unicode(self, options): diff --git a/deluge/plugins/Blocklist/deluge/plugins/blocklist/core.py b/deluge/plugins/Blocklist/deluge/plugins/blocklist/core.py index ff465db22..aa21fed53 100644 --- a/deluge/plugins/Blocklist/deluge/plugins/blocklist/core.py +++ b/deluge/plugins/Blocklist/deluge/plugins/blocklist/core.py @@ -170,7 +170,7 @@ class Core(CorePluginBase): """ needs_blocklist_import = False - for key in config.keys(): + for key in config: if key == 'whitelisted': saved = set(self.config[key]) update = set(config[key]) diff --git a/deluge/plugins/Extractor/deluge/plugins/extractor/core.py b/deluge/plugins/Extractor/deluge/plugins/extractor/core.py index dab0a0c9c..649e91334 100644 --- a/deluge/plugins/Extractor/deluge/plugins/extractor/core.py +++ b/deluge/plugins/Extractor/deluge/plugins/extractor/core.py @@ -163,7 +163,7 @@ class Core(CorePluginBase): @export def set_config(self, config): 'sets the config dictionary' - for key in config.keys(): + for key in config: self.config[key] = config[key] self.config.save() diff --git a/deluge/plugins/Label/deluge/plugins/label/core.py b/deluge/plugins/Label/deluge/plugins/label/core.py index 7f78ed028..9e3b4987c 100644 --- a/deluge/plugins/Label/deluge/plugins/label/core.py +++ b/deluge/plugins/Label/deluge/plugins/label/core.py @@ -108,7 +108,7 @@ class Core(CorePluginBase): pass def init_filter_dict(self): - filter_dict = dict([(label, 0) for label in self.labels.keys()]) + filter_dict = dict([(label, 0) for label in self.labels]) filter_dict['All'] = len(self.torrents) return filter_dict @@ -143,8 +143,8 @@ class Core(CorePluginBase): *add any new keys in OPTIONS_DEFAULTS *set all None values to default <-fix development config """ - log.debug(list(self.labels.keys())) - for key in self.labels.keys(): + log.debug(list(self.labels)) + for key in self.labels: options = dict(OPTIONS_DEFAULTS) options.update(self.labels[key]) self.labels[key] = options @@ -160,7 +160,7 @@ class Core(CorePluginBase): @export def get_labels(self): - return sorted(self.labels.keys()) + return sorted(self.labels) # Labels: @export @@ -260,7 +260,7 @@ class Core(CorePluginBase): } """ check_input(label_id in self.labels, _('Unknown Label')) - for key in options_dict.keys(): + for key in options_dict: if key not in OPTIONS_DEFAULTS: raise Exception('label: Invalid options_dict key:%s' % key) diff --git a/deluge/plugins/Label/deluge/plugins/label/gtkui/sidebar_menu.py b/deluge/plugins/Label/deluge/plugins/label/gtkui/sidebar_menu.py index 13e162ae6..07a4f2b1f 100644 --- a/deluge/plugins/Label/deluge/plugins/label/gtkui/sidebar_menu.py +++ b/deluge/plugins/Label/deluge/plugins/label/gtkui/sidebar_menu.py @@ -174,7 +174,7 @@ class OptionsDialog(object): self.dialog.run() def load_options(self, options): - log.debug(list(options.keys())) + log.debug(list(options)) for spin_id in self.spin_ids + self.spin_int_ids: self.glade.get_widget(spin_id).set_value(options[spin_id]) diff --git a/deluge/plugins/Notifications/deluge/plugins/notifications/core.py b/deluge/plugins/Notifications/deluge/plugins/notifications/core.py index 15819d141..2ba001328 100644 --- a/deluge/plugins/Notifications/deluge/plugins/notifications/core.py +++ b/deluge/plugins/Notifications/deluge/plugins/notifications/core.py @@ -206,7 +206,7 @@ class Core(CorePluginBase, CoreNotifications): @export def set_config(self, config): 'sets the config dictionary' - for key in config.keys(): + for key in config: self.config[key] = config[key] self.config.save() diff --git a/deluge/plugins/Scheduler/deluge/plugins/scheduler/core.py b/deluge/plugins/Scheduler/deluge/plugins/scheduler/core.py index 6b5a9c04f..30a692ef8 100644 --- a/deluge/plugins/Scheduler/deluge/plugins/scheduler/core.py +++ b/deluge/plugins/Scheduler/deluge/plugins/scheduler/core.py @@ -148,7 +148,7 @@ class Core(CorePluginBase): @export() def set_config(self, config): 'sets the config dictionary' - for key in config.keys(): + for key in config: self.config[key] = config[key] self.config.save() self.do_schedule(False) diff --git a/deluge/plugins/Stats/deluge/plugins/stats/core.py b/deluge/plugins/Stats/deluge/plugins/stats/core.py index ba52317bb..6b03e762f 100644 --- a/deluge/plugins/Stats/deluge/plugins/stats/core.py +++ b/deluge/plugins/Stats/deluge/plugins/stats/core.py @@ -208,7 +208,7 @@ class Core(CorePluginBase): @export def set_config(self, config): 'sets the config dictionary' - for key in config.keys(): + for key in config: self.config[key] = config[key] self.config.save() diff --git a/deluge/plugins/Stats/deluge/plugins/stats/gtkui.py b/deluge/plugins/Stats/deluge/plugins/stats/gtkui.py index 0a83f7ef2..ea2641680 100644 --- a/deluge/plugins/Stats/deluge/plugins/stats/gtkui.py +++ b/deluge/plugins/Stats/deluge/plugins/stats/gtkui.py @@ -129,7 +129,7 @@ class GraphsTab(Tab): return False def update(self): - d1 = client.stats.get_stats(list(self.graph.stat_info.keys()), self.selected_interval) + d1 = client.stats.get_stats(list(self.graph.stat_info), self.selected_interval) d1.addCallback(self.graph.set_stats) def _update_complete(result): diff --git a/deluge/plugins/WebUi/deluge/plugins/webui/core.py b/deluge/plugins/WebUi/deluge/plugins/webui/core.py index 5951c55e1..45f780c56 100644 --- a/deluge/plugins/WebUi/deluge/plugins/webui/core.py +++ b/deluge/plugins/WebUi/deluge/plugins/webui/core.py @@ -107,7 +107,7 @@ class Core(CorePluginBase): if not action: action = 'restart' - for key in config.keys(): + for key in config: self.config[key] = config[key] self.config.save() diff --git a/deluge/scripts/create_plugin.py b/deluge/scripts/create_plugin.py index e2268b818..ed49c3dff 100644 --- a/deluge/scripts/create_plugin.py +++ b/deluge/scripts/create_plugin.py @@ -132,7 +132,7 @@ class Core(CorePluginBase): @export def set_config(self, config): \"\"\"Sets the config dictionary\"\"\" - for key in config.keys(): + for key in config: self.config[key] = config[key] self.config.save() diff --git a/deluge/tests/test_json_api.py b/deluge/tests/test_json_api.py index 1ffc9b193..b04175048 100644 --- a/deluge/tests/test_json_api.py +++ b/deluge/tests/test_json_api.py @@ -137,7 +137,7 @@ class JSONCustomUserTestCase(JSONBase): def test_handle_request_auth_error(self): yield self.connect_client() json = JSON() - auth_conf = {'session_timeout': 10, 'sessions': []} + auth_conf = {'session_timeout': 10, 'sessions': {}} Auth(auth_conf) # Must create the component # Must be called to update remote methods in json object @@ -177,7 +177,7 @@ class RPCRaiseDelugeErrorJSONTestCase(JSONBase): def get_session_id(s_id): return s_id self.patch(deluge.ui.web.auth, 'get_session_id', get_session_id) - auth_conf = {'session_timeout': 10, 'sessions': []} + auth_conf = {'session_timeout': 10, 'sessions': {}} auth = Auth(auth_conf) request = Request(MagicMock(), False) request.base = '' @@ -187,7 +187,7 @@ class RPCRaiseDelugeErrorJSONTestCase(JSONBase): self.assertTrue('testclass.test' in methods) request = MagicMock() - request.getCookie = MagicMock(return_value=list(auth.config['sessions'].keys())[0]) + request.getCookie = MagicMock(return_value=list(auth.config['sessions'])[0]) json_data = {'method': 'testclass.test', 'id': 0, 'params': []} request.json = json_lib.dumps(json_data) request_id, result, error = json._handle_request(request) diff --git a/deluge/tests/test_sessionproxy.py b/deluge/tests/test_sessionproxy.py index e65b90f83..9b3b128c5 100644 --- a/deluge/tests/test_sessionproxy.py +++ b/deluge/tests/test_sessionproxy.py @@ -35,7 +35,7 @@ class Core(object): def get_torrent_status(self, torrent_id, keys, diff=False): if not keys: - keys = list(self.torrents[torrent_id].keys()) + keys = list(self.torrents[torrent_id]) if not diff: ret = {} @@ -57,9 +57,9 @@ class Core(object): def get_torrents_status(self, filter_dict, keys, diff=False): if not filter_dict: - filter_dict['id'] = list(self.torrents.keys()) + filter_dict['id'] = list(self.torrents) if not keys: - keys = list(self.torrents['a'].keys()) + keys = list(self.torrents['a']) if not diff: if 'id' in filter_dict: torrents = filter_dict['id'] diff --git a/deluge/ui/baseargparser.py b/deluge/ui/baseargparser.py index c320a8f26..cfafa9ad9 100644 --- a/deluge/ui/baseargparser.py +++ b/deluge/ui/baseargparser.py @@ -39,7 +39,7 @@ def find_subcommand(self, args=None, sys_argv=True): for x in self._subparsers._actions: if not isinstance(x, argparse._SubParsersAction): continue - for sp_name in x._name_parser_map.keys(): + for sp_name in x._name_parser_map: if sp_name in args: subcommand_found = args.index(sp_name) diff --git a/deluge/ui/client.py b/deluge/ui/client.py index 452f767a3..a494de576 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -396,12 +396,9 @@ class DaemonSSLProxy(DaemonProxy): self.authentication_level = result # We need to tell the daemon what events we're interested in receiving if self.__factory.event_handlers: - self.call('daemon.set_event_interest', - list(self.__factory.event_handlers.keys())) - + self.call('daemon.set_event_interest', list(self.__factory.event_handlers)) self.call('core.get_auth_levels_mappings').addCallback( - self.__on_auth_levels_mappings - ) + self.__on_auth_levels_mappings) login_deferred.callback(result) diff --git a/deluge/ui/common.py b/deluge/ui/common.py index 8c7eb314e..5a1b1c1e0 100644 --- a/deluge/ui/common.py +++ b/deluge/ui/common.py @@ -207,7 +207,7 @@ class TorrentInfo(object): item.update(paths[path]) item['download'] = True - file_tree = FileTree2(list(paths.keys())) + file_tree = FileTree2(list(paths)) file_tree.walk(walk) else: def walk(path, item): @@ -386,7 +386,7 @@ class FileTree2(object): :type callback: function """ def walk(directory, parent_path): - for path in directory['contents'].keys(): + for path in list(directory['contents']): full_path = os.path.join(parent_path, path).replace('\\', '/') if directory['contents'][path]['type'] == 'dir': directory['contents'][path] = callback( @@ -466,7 +466,7 @@ class FileTree(object): :type callback: function """ def walk(directory, parent_path): - for path in directory.keys(): + for path in list(directory): full_path = os.path.join(parent_path, path) if isinstance(directory[path], dict): directory[path] = callback(full_path, directory[path]) or directory[path] diff --git a/deluge/ui/console/cmdline/commands/config.py b/deluge/ui/console/cmdline/commands/config.py index a4be506ab..cf63e0033 100644 --- a/deluge/ui/console/cmdline/commands/config.py +++ b/deluge/ui/console/cmdline/commands/config.py @@ -86,11 +86,11 @@ class Command(BaseCommand): def _get_config(self, options): def _on_get_config(config): - keys = sorted(config.keys()) - s = '' - for key in keys: + string = '' + for key in sorted(config): if key not in options.values: continue + color = '{!white,black,bold!}' value = config[key] try: @@ -107,8 +107,8 @@ class Command(BaseCommand): new_value.append('%s%s' % (color, line)) value = '\n'.join(new_value) - s += '%s: %s%s\n' % (key, color, value) - self.console.write(s.strip()) + string += '%s: %s%s\n' % (key, color, value) + self.console.write(string.strip()) return client.core.get_config().addCallback(_on_get_config) @@ -123,7 +123,7 @@ class Command(BaseCommand): self.console.write('{!error!}%s' % ex) return - if key not in list(config.keys()): + if key not in config: self.console.write('{!error!}Invalid key: %s' % key) return @@ -141,4 +141,4 @@ class Command(BaseCommand): return client.core.set_config({key: val}).addCallback(on_set_config) def complete(self, text): - return [k for k in component.get('CoreConfig').keys() if k.startswith(text)] + return [k for k in component.get('CoreConfig') if k.startswith(text)] diff --git a/deluge/ui/console/cmdline/commands/manage.py b/deluge/ui/console/cmdline/commands/manage.py index 71e29a9c0..73be5b938 100644 --- a/deluge/ui/console/cmdline/commands/manage.py +++ b/deluge/ui/console/cmdline/commands/manage.py @@ -82,7 +82,7 @@ class Command(BaseCommand): return request_options.append(opt) if not request_options: - request_options = [opt for opt in torrent_options.keys()] + request_options = list(torrent_options) request_options.append('name') d = client.core.get_torrents_status({'id': torrent_ids}, request_options) diff --git a/deluge/ui/console/modes/torrentlist/torrentview.py b/deluge/ui/console/modes/torrentlist/torrentview.py index b3b1aaba5..af4b88147 100644 --- a/deluge/ui/console/modes/torrentlist/torrentview.py +++ b/deluge/ui/console/modes/torrentlist/torrentview.py @@ -235,7 +235,7 @@ class TorrentView(InputKeyHandler): # Get first element so we can check if it has given field # and if it's a string - first_element = state[list(state.keys())[0]] + first_element = state[list(state)[0]] if field in first_element: def sort_key(s): try: diff --git a/deluge/ui/gtkui/dialogs.py b/deluge/ui/gtkui/dialogs.py index 1738ae72d..7cbe73d31 100644 --- a/deluge/ui/gtkui/dialogs.py +++ b/deluge/ui/gtkui/dialogs.py @@ -272,7 +272,7 @@ class AccountDialog(BaseDialog): self.authlevel_combo = gtk.ComboBoxText() active_idx = None - for idx, level in enumerate(levels_mapping.keys()): + for idx, level in enumerate(levels_mapping): self.authlevel_combo.append_text(level) if authlevel and authlevel == level: active_idx = idx diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index b3864dc9d..a02094aa2 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -411,7 +411,7 @@ class MenuBar(component.Component): 'menuitem_max_connections': 'max_connections', 'menuitem_upload_slots': 'max_upload_slots' } - if widget.get_name() in list(funcs.keys()): + if widget.get_name() in funcs: torrent_ids = component.get('TorrentView').get_selected_torrents() client.core.set_torrent_options(torrent_ids, {funcs[widget.get_name()]: -1}) diff --git a/deluge/ui/gtkui/options_tab.py b/deluge/ui/gtkui/options_tab.py index a1089b1d0..a0713dbfe 100644 --- a/deluge/ui/gtkui/options_tab.py +++ b/deluge/ui/gtkui/options_tab.py @@ -116,7 +116,7 @@ class OptionsTab(Tab): # We only want to update values that have been applied in the core. This # is so we don't overwrite the user changes that haven't been applied yet. if self.prev_status is None: - self.prev_status = {}.fromkeys(list(status.keys()), None) + self.prev_status = {}.fromkeys(list(status), None) if status != self.prev_status: if status['max_download_speed'] != self.prev_status['max_download_speed']: diff --git a/deluge/ui/gtkui/path_chooser.py b/deluge/ui/gtkui/path_chooser.py index bbd64593b..35df8ae72 100644 --- a/deluge/ui/gtkui/path_chooser.py +++ b/deluge/ui/gtkui/path_chooser.py @@ -60,7 +60,7 @@ class PathChoosersHandler(component.Component): self.config_properties.update(config) for chooser in self.path_choosers: chooser.set_config(config) - keys = list(self.config_keys_to_funcs_mapping.keys()) + keys = list(self.config_keys_to_funcs_mapping) keys += self.paths_list_keys client.core.get_config_values(keys).addCallback(_on_config_values) @@ -109,7 +109,7 @@ class PathChoosersHandler(component.Component): chooser.set_values(values) def get_config_keys(self): - keys = list(self.config_keys_to_funcs_mapping.keys()) + keys = list(self.config_keys_to_funcs_mapping) keys += self.paths_list_keys return keys diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 896900a44..c9d1a39db 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -801,7 +801,7 @@ class Preferences(component.Component): def update_dependent_widgets(name, value): dependency = dependents[name] - for dep in dependency.keys(): + for dep in dependency: if dep in path_choosers: depwidget = path_choosers[dep] else: diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtkui/statusbar.py index 8521ee1cb..27ade3dbb 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtkui/statusbar.py @@ -287,7 +287,7 @@ class StatusBar(component.Component): This is called when we receive a ConfigValueChangedEvent from the core. """ - if key in list(self.config_value_changed_dict.keys()): + if key in self.config_value_changed_dict: self.config_value_changed_dict[key](value) def _on_max_connections_global(self, max_connections): diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index a93acd8b1..5cae9a097 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -179,7 +179,7 @@ class SystemTray(component.Component): def config_value_changed(self, key, value): """This is called when we received a config_value_changed signal from the core.""" - if key in list(self.config_value_changed_dict.keys()): + if key in self.config_value_changed_dict: self.config_value_changed_dict[key](value) def _on_max_download_speed(self, max_download_speed): diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index 8e2fdf802..44796178c 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -413,15 +413,15 @@ class TorrentView(ListView, component.Component): if columns is None: # We need to iterate through all columns - columns = list(self.columns.keys()) + columns = list(self.columns) # Iterate through supplied list of columns to update for column in columns: # Make sure column is visible and has 'status_field' set. # If not, we can ignore it. - if self.columns[column].column.get_visible() is True \ - and self.columns[column].hidden is False \ - and self.columns[column].status_field is not None: + if (self.columns[column].column.get_visible() is True + and self.columns[column].hidden is False + and self.columns[column].status_field is not None): for field in self.columns[column].status_field: status_keys.append(field) self.columns_to_update.append(column) @@ -486,7 +486,7 @@ class TorrentView(ListView, component.Component): # Get the columns to update from one of the torrents if status: - torrent_id = list(status.keys())[0] + torrent_id = list(status)[0] fields_to_update = [] for column in self.columns_to_update: column_index = self.get_column_index(column) @@ -626,7 +626,7 @@ class TorrentView(ListView, component.Component): return {} def get_visible_torrents(self): - return list(self.status.keys()) + return list(self.status) # Callbacks # def on_button_press_event(self, widget, event): diff --git a/deluge/ui/sessionproxy.py b/deluge/ui/sessionproxy.py index b288cf54e..912d58625 100644 --- a/deluge/ui/sessionproxy.py +++ b/deluge/ui/sessionproxy.py @@ -125,7 +125,7 @@ class SessionProxy(component.Component): # Keep track of keys we need to request from the core keys_to_get = [] if not keys: - keys = self.torrents[torrent_id][1].keys() + keys = list(self.torrents[torrent_id][1]) for key in keys: if time() - self.cache_times[torrent_id].get(key, 0.0) > self.cache_time: @@ -192,7 +192,7 @@ class SessionProxy(component.Component): # Create the status dict if not torrent_ids: - torrent_ids = list(result.keys()) + torrent_ids = list(result) return self.create_status_dict(torrent_ids, keys) @@ -216,13 +216,14 @@ class SessionProxy(component.Component): if not filter_dict: # This means we want all the torrents status # We get a list of any torrent_ids with expired status dicts - to_fetch = find_torrents_to_fetch(list(self.torrents.keys())) + torrents_list = list(self.torrents) + to_fetch = find_torrents_to_fetch(torrents_list) if to_fetch: d = client.core.get_torrents_status({'id': to_fetch}, keys, True) - return d.addCallback(on_status, list(self.torrents.keys()), keys) + return d.addCallback(on_status, torrents_list, keys) # Don't need to fetch anything - return maybeDeferred(self.create_status_dict, list(self.torrents.keys()), keys) + return maybeDeferred(self.create_status_dict, torrents_list, keys) if len(filter_dict) == 1 and 'id' in filter_dict: # At this point we should have a filter with just "id" in it diff --git a/deluge/ui/web/auth.py b/deluge/ui/web/auth.py index 4438004f6..d80327f57 100644 --- a/deluge/ui/web/auth.py +++ b/deluge/ui/web/auth.py @@ -90,10 +90,8 @@ class Auth(JSONComponent): self.worker.stop() def _clean_sessions(self): - session_ids = list(self.config['sessions'].keys()) - now = time.gmtime() - for session_id in session_ids: + for session_id in list(self.config['sessions']): session = self.config['sessions'][session_id] if 'expires' not in session: diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index ac946f627..72052f7da 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -899,7 +899,7 @@ class WebApi(JSONComponent): :type config: dictionary """ web_config = component.get('DelugeWeb').config - for key in config.keys(): + for key in config: if key in ['sessions', 'pwd_salt', 'pwd_sha1']: log.warn('Ignored attempt to overwrite web config key: %s', key) continue @@ -918,7 +918,7 @@ class WebApi(JSONComponent): """ return { - 'enabled_plugins': list(component.get('Web.PluginManager').plugins.keys()), + 'enabled_plugins': list(component.get('Web.PluginManager').plugins), 'available_plugins': component.get('Web.PluginManager').available_plugins } @@ -62,7 +62,7 @@ def generate(): Return the generated output. """ # the keys are sorted in the .mo file - keys = sorted(MESSAGES.keys()) + keys = sorted(MESSAGES) offsets = [] ids = strs = '' for _id in keys: |