From e26182c96ec3e5b645b429d28526c1d62cc65516 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Wed, 1 Apr 2020 15:31:15 -0700 Subject: [PATCH] Remove list(dict.keys()) --> dict.keys() and list(dict.values()) --> dict.values() --- plexpy/api2.py | 2 +- plexpy/config.py | 4 ++-- plexpy/database.py | 2 +- plexpy/datatables.py | 2 +- plexpy/notification_handler.py | 6 +++--- plexpy/notifiers.py | 8 ++++---- plexpy/pmsconnect.py | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plexpy/api2.py b/plexpy/api2.py index 9aed4b82..7d13e2fb 100644 --- a/plexpy/api2.py +++ b/plexpy/api2.py @@ -61,7 +61,7 @@ else: class API2(object): def __init__(self, **kwargs): - self._api_valid_methods = list(self._api_docs().keys()) + self._api_valid_methods = self._api_docs().keys() self._api_authenticated = False self._api_out_type = 'json' # default self._api_msg = None diff --git a/plexpy/config.py b/plexpy/config.py index 4e36156d..f917ecb5 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -692,7 +692,7 @@ class Config(object): """ Initialize the config with values from a file """ self._config_file = config_file self._config = ConfigObj(self._config_file, encoding='utf-8') - for key in list(_CONFIG_DEFINITIONS.keys()): + for key in _CONFIG_DEFINITIONS: self.check_setting(key) self._upgrade() self._blacklist() @@ -752,7 +752,7 @@ class Config(object): new_config[key][subkey] = value # next make sure that everything we expect to have defined is so - for key in list(_CONFIG_DEFINITIONS.keys()): + for key in _CONFIG_DEFINITIONS: key, definition_type, section, ini_key, default = self._define(key) self.check_setting(key) if section not in new_config: diff --git a/plexpy/database.py b/plexpy/database.py index 02102ded..047f30c8 100644 --- a/plexpy/database.py +++ b/plexpy/database.py @@ -202,7 +202,7 @@ class MonitorDatabase(object): trans_type = 'update' changes_before = self.connection.total_changes - gen_params = lambda my_dict: [x + " = ?" for x in list(my_dict.keys())] + gen_params = lambda my_dict: [x + " = ?" for x in my_dict] update_query = "UPDATE " + table_name + " SET " + ", ".join(gen_params(value_dict)) + \ " WHERE " + " AND ".join(gen_params(key_dict)) diff --git a/plexpy/datatables.py b/plexpy/datatables.py index fdc0b1a5..a666a9fb 100644 --- a/plexpy/datatables.py +++ b/plexpy/datatables.py @@ -99,7 +99,7 @@ class DataTables(object): filtered = self.ssp_db.select(query, args=args) # Remove NULL rows - filtered = [row for row in filtered if not all(v is None for v in list(row.values()))] + filtered = [row for row in filtered if not all(v is None for v in row.values())] # Build grand totals totalcount = self.ssp_db.select('SELECT COUNT(id) as total_count from %s' % table_name)[0]['total_count'] diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 48a3c465..8b9307da 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -1233,7 +1233,7 @@ def strip_tag(data, agent_id=None): 'u': [], 'a': ['href'], 'font': ['color']} - data = bleach.clean(data, tags=list(whitelist.keys()), attributes=whitelist, strip=True) + data = bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) elif agent_id == 13: # Allow tags b, i, code, pre, a[href] for Telegram @@ -1242,7 +1242,7 @@ def strip_tag(data, agent_id=None): 'code': [], 'pre': [], 'a': ['href']} - data = bleach.clean(data, tags=list(whitelist.keys()), attributes=whitelist, strip=True) + data = bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) elif agent_id in (10, 14, 20, 25): # Don't remove tags for Email, Slack, Discord, and Webhook @@ -1250,7 +1250,7 @@ def strip_tag(data, agent_id=None): else: whitelist = {} - data = bleach.clean(data, tags=list(whitelist.keys()), attributes=whitelist, strip=True) + data = bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) # Resubstitute temporary tokens for < and > in parameter prefix and suffix return data.replace('%temp_lt_token%', '<').replace('%temp_gt_token%', '>') diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index 20f8a668..7ad868ad 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -2787,7 +2787,7 @@ class SCRIPTS(Notifier): for root, dirs, files in os.walk(scriptdir): for f in files: name, ext = os.path.splitext(f) - if ext in list(self.script_exts.keys()): + if ext in self.script_exts: rfp = os.path.join(os.path.relpath(root, scriptdir), f) fp = os.path.join(root, f) scripts[fp] = rfp @@ -2931,7 +2931,7 @@ class SCRIPTS(Notifier): def _return_config_options(self): config_option = [{'label': 'Supported File Types', 'description': '' + \ - ', '.join(list(self.script_exts.keys())) + '', + ', '.join(self.script_exts) + '', 'input_type': 'help' }, {'label': 'Script Folder', @@ -3719,8 +3719,8 @@ def upgrade_config_to_db(): for script, actions in script_actions.items(): if any(agent_actions[a] for a in actions): temp_config = notifier_config - temp_config.update({a: 0 for a in list(agent_actions.keys())}) - temp_config.update({a + '_subject': '' for a in list(agent_actions.keys())}) + temp_config.update({a: 0 for a in agent_actions}) + temp_config.update({a + '_subject': '' for a in agent_actions}) for a in actions: if agent_actions[a]: temp_config[a] = agent_actions[a] diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index ec8641dd..06725fbe 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -2356,7 +2356,7 @@ class PmsConnect(object): hub_identifier = helpers.get_xml_attr(h, 'hubIdentifier') if size == '0' or not hub_identifier.startswith('collection.related') or \ - media_type not in list(children_results_list.keys()): + media_type not in children_results_list: continue result_data = [] @@ -2811,7 +2811,7 @@ class PmsConnect(object): for h in hubs: if helpers.get_xml_attr(h, 'size') == '0' or \ - helpers.get_xml_attr(h, 'type') not in list(search_results_list.keys()): + helpers.get_xml_attr(h, 'type') not in search_results_list: continue if h.getElementsByTagName('Video'): @@ -2843,7 +2843,7 @@ class PmsConnect(object): metadata = self.get_metadata_details(rating_key=rating_key) search_results_list[metadata['media_type']].append(metadata) - output = {'results_count': sum(len(s) for s in list(search_results_list.values())), + output = {'results_count': sum(len(s) for s in search_results_list.values()), 'results_list': search_results_list }