diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2017-03-16 21:39:57 +0000 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2017-03-16 23:20:56 +0000 |
commit | af7e83bc76dc2db837ebcabba612dbccc9aac9e7 (patch) | |
tree | 025fbb6f57ca6f3513d218e59c78095abec729c0 /deluge/ui | |
parent | 4a274466acf55a8b5617b630ab4c7253827025bf (diff) | |
download | deluge-af7e83bc76dc2db837ebcabba612dbccc9aac9e7.tar.gz deluge-af7e83bc76dc2db837ebcabba612dbccc9aac9e7.tar.bz2 deluge-af7e83bc76dc2db837ebcabba612dbccc9aac9e7.zip |
Replace/remove usage of dict.keys()
Diffstat (limited to 'deluge/ui')
-rw-r--r-- | deluge/ui/baseargparser.py | 2 | ||||
-rw-r--r-- | deluge/ui/client.py | 7 | ||||
-rw-r--r-- | deluge/ui/common.py | 6 | ||||
-rw-r--r-- | deluge/ui/console/cmdline/commands/config.py | 14 | ||||
-rw-r--r-- | deluge/ui/console/cmdline/commands/manage.py | 2 | ||||
-rw-r--r-- | deluge/ui/console/modes/torrentlist/torrentview.py | 2 | ||||
-rw-r--r-- | deluge/ui/gtkui/dialogs.py | 2 | ||||
-rw-r--r-- | deluge/ui/gtkui/menubar.py | 2 | ||||
-rw-r--r-- | deluge/ui/gtkui/options_tab.py | 2 | ||||
-rw-r--r-- | deluge/ui/gtkui/path_chooser.py | 4 | ||||
-rw-r--r-- | deluge/ui/gtkui/preferences.py | 2 | ||||
-rw-r--r-- | deluge/ui/gtkui/statusbar.py | 2 | ||||
-rw-r--r-- | deluge/ui/gtkui/systemtray.py | 2 | ||||
-rw-r--r-- | deluge/ui/gtkui/torrentview.py | 12 | ||||
-rw-r--r-- | deluge/ui/sessionproxy.py | 11 | ||||
-rw-r--r-- | deluge/ui/web/auth.py | 4 | ||||
-rw-r--r-- | deluge/ui/web/json_api.py | 4 |
17 files changed, 38 insertions, 42 deletions
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 } |