mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 15:32:38 -07:00
Remove list(dict.items()) -- >dict.items()
This commit is contained in:
parent
2b0e7daf7c
commit
ad112e0a44
12 changed files with 38 additions and 38 deletions
|
@ -546,7 +546,7 @@ class ActivityProcessor(object):
|
|||
if state:
|
||||
values['state'] = state
|
||||
|
||||
for k, v in list(kwargs.items()):
|
||||
for k, v in kwargs.items():
|
||||
values[k] = v
|
||||
|
||||
keys = {'session_key': session_key}
|
||||
|
|
|
@ -231,7 +231,7 @@ class API2(object):
|
|||
|
||||
if search:
|
||||
logger.api_debug("Tautulli APIv2 :: Searching log values for '%s'" % search)
|
||||
tt = [d for d in templog for k, v in list(d.items()) if search.lower() in v.lower()]
|
||||
tt = [d for d in templog for k, v in d.items() if search.lower() in v.lower()]
|
||||
|
||||
if len(tt):
|
||||
templog = tt
|
||||
|
@ -239,7 +239,7 @@ class API2(object):
|
|||
if regex:
|
||||
tt = []
|
||||
for l in templog:
|
||||
stringdict = ' '.join('{}{}'.format(k, v) for k, v in list(l.items()))
|
||||
stringdict = ' '.join('{}{}'.format(k, v) for k, v in l.items())
|
||||
if reg.search(stringdict):
|
||||
tt.append(l)
|
||||
|
||||
|
@ -275,10 +275,10 @@ class API2(object):
|
|||
config = {}
|
||||
|
||||
# Truthify the dict
|
||||
for k, v in list(conf.items()):
|
||||
for k, v in conf.items():
|
||||
if isinstance(v, dict):
|
||||
d = {}
|
||||
for kk, vv in list(v.items()):
|
||||
for kk, vv in v.items():
|
||||
if vv == '0' or vv == '1':
|
||||
d[kk] = bool(vv)
|
||||
else:
|
||||
|
|
|
@ -699,8 +699,8 @@ class Config(object):
|
|||
""" Add tokens and passwords to blacklisted words in logger """
|
||||
blacklist = set()
|
||||
|
||||
for key, subkeys in list(self._config.items()):
|
||||
for subkey, value in list(subkeys.items()):
|
||||
for key, subkeys in self._config.items():
|
||||
for subkey, value in subkeys.items():
|
||||
if isinstance(value, basestring) and len(value.strip()) > 5 and \
|
||||
subkey.upper() not in _WHITELIST_KEYS and any(bk in subkey.upper() for bk in _BLACKLIST_KEYS):
|
||||
blacklist.add(value.strip())
|
||||
|
@ -743,10 +743,10 @@ class Config(object):
|
|||
|
||||
# first copy over everything from the old config, even if it is not
|
||||
# correctly defined to keep from losing data
|
||||
for key, subkeys in list(self._config.items()):
|
||||
for key, subkeys in self._config.items():
|
||||
if key not in new_config:
|
||||
new_config[key] = {}
|
||||
for subkey, value in list(subkeys.items()):
|
||||
for subkey, value in subkeys.items():
|
||||
new_config[key][subkey] = value
|
||||
|
||||
# next make sure that everything we expect to have defined is so
|
||||
|
@ -794,7 +794,7 @@ class Config(object):
|
|||
"""
|
||||
Given a big bunch of key value pairs, apply them to the ini.
|
||||
"""
|
||||
for name, value in list(kwargs.items()):
|
||||
for name, value in kwargs.items():
|
||||
key, definition_type, section, ini_key, default = self._define(name)
|
||||
self._config[section][ini_key] = definition_type(value)
|
||||
|
||||
|
|
|
@ -691,7 +691,7 @@ class DataFactory(object):
|
|||
for item in result:
|
||||
# Rename Mystery platform names
|
||||
platform = common.PLATFORM_NAME_OVERRIDES.get(item['platform'], item['platform'])
|
||||
platform_name = next((v for k, v in list(common.PLATFORM_NAMES.items()) if k in platform.lower()), 'default')
|
||||
platform_name = next((v for k, v in common.PLATFORM_NAMES.items() if k in platform.lower()), 'default')
|
||||
|
||||
row = {'total_plays': item['total_plays'],
|
||||
'total_duration': item['total_duration'],
|
||||
|
@ -1033,7 +1033,7 @@ class DataFactory(object):
|
|||
'pre_tautulli': pre_tautulli
|
||||
}
|
||||
|
||||
stream_output = {k: v or '' for k, v in list(stream_output.items())}
|
||||
stream_output = {k: v or '' for k, v in stream_output.items()}
|
||||
return stream_output
|
||||
|
||||
def get_metadata_details(self, rating_key='', guid=''):
|
||||
|
@ -1595,7 +1595,7 @@ class DataFactory(object):
|
|||
# function to map rating keys pairs
|
||||
def get_pairs(old, new):
|
||||
pairs = {}
|
||||
for k, v in list(old.items()):
|
||||
for k, v in old.items():
|
||||
if k in new:
|
||||
pairs.update({v['rating_key']: new[k]['rating_key']})
|
||||
if 'children' in old[k]:
|
||||
|
@ -1610,7 +1610,7 @@ class DataFactory(object):
|
|||
|
||||
if mapping:
|
||||
logger.info("Tautulli DataFactory :: Updating metadata in the database.")
|
||||
for old_key, new_key in list(mapping.items()):
|
||||
for old_key, new_key in mapping.items():
|
||||
metadata = pms_connect.get_metadata_details(new_key)
|
||||
|
||||
if metadata:
|
||||
|
|
|
@ -354,7 +354,7 @@ def replace_all(text, dic, normalize=False):
|
|||
if not text:
|
||||
return ''
|
||||
|
||||
for i, j in list(dic.items()):
|
||||
for i, j in dic.items():
|
||||
if normalize:
|
||||
try:
|
||||
if sys.platform == 'darwin':
|
||||
|
@ -583,7 +583,7 @@ def sanitize(obj):
|
|||
elif isinstance(obj, list):
|
||||
return [sanitize(o) for o in obj]
|
||||
elif isinstance(obj, dict):
|
||||
return {k: sanitize(v) for k, v in list(obj.items())}
|
||||
return {k: sanitize(v) for k, v in obj.items()}
|
||||
elif isinstance(obj, tuple):
|
||||
return tuple(sanitize(list(obj)))
|
||||
else:
|
||||
|
@ -1242,7 +1242,7 @@ def traverse_map(obj, func):
|
|||
|
||||
elif isinstance(obj, dict):
|
||||
new_obj = {}
|
||||
for k, v in list(obj.items()):
|
||||
for k, v in obj.items():
|
||||
new_obj[traverse_map(k, func)] = traverse_map(v, func)
|
||||
|
||||
else:
|
||||
|
@ -1267,7 +1267,7 @@ def mask_config_passwords(config):
|
|||
cfg['value'] = ' '
|
||||
|
||||
elif isinstance(config, dict):
|
||||
for cfg, val in list(config.items()):
|
||||
for cfg, val in config.items():
|
||||
# Check for a password config keys and if the password is not blank
|
||||
if 'password' in cfg and val != '':
|
||||
# Set the password to blank so it is not exposed in the HTML form
|
||||
|
|
|
@ -252,7 +252,7 @@ def update_labels():
|
|||
% section_id)
|
||||
|
||||
error_keys = set()
|
||||
for rating_key, labels in list(key_mappings.items()):
|
||||
for rating_key, labels in key_mappings.items():
|
||||
try:
|
||||
labels = ';'.join(labels)
|
||||
monitor_db.action('UPDATE session_history_metadata SET labels = ? '
|
||||
|
@ -586,7 +586,7 @@ class Libraries(object):
|
|||
if search_value:
|
||||
searchable_columns = [d['data'] for d in json_data['columns'] if d['searchable']] + ['title']
|
||||
for row in rows:
|
||||
for k,v in list(row.items()):
|
||||
for k,v in row.items():
|
||||
if k in searchable_columns and search_value in v.lower():
|
||||
results.append(row)
|
||||
break
|
||||
|
|
|
@ -62,7 +62,7 @@ def blacklist_config(config):
|
|||
blacklist = set()
|
||||
blacklist_keys = ['HOOK', 'APIKEY', 'KEY', 'PASSWORD', 'TOKEN']
|
||||
|
||||
for key, value in list(config.items()):
|
||||
for key, value in config.items():
|
||||
if isinstance(value, basestring) and len(value.strip()) > 5 and \
|
||||
key.upper() not in _WHITELIST_KEYS and (key.upper() in blacklist_keys or
|
||||
any(bk in key.upper() for bk in _BLACKLIST_KEYS)):
|
||||
|
|
|
@ -241,7 +241,7 @@ def set_newsletter_config(newsletter_id=None, agent_id=None, **kwargs):
|
|||
email_config = {k[len(email_config_prefix):]: kwargs.pop(k)
|
||||
for k in list(kwargs.keys()) if k.startswith(email_config_prefix)}
|
||||
|
||||
for cfg, val in list(email_config.items()):
|
||||
for cfg, val in email_config.items():
|
||||
# Check for a password config keys and a blank password from the HTML form
|
||||
if 'password' in cfg and val == ' ':
|
||||
# Get the previous password so we don't overwrite it with a blank value
|
||||
|
@ -426,7 +426,7 @@ class Newsletter(object):
|
|||
return default
|
||||
|
||||
new_config = {}
|
||||
for k, v in list(default.items()):
|
||||
for k, v in default.items():
|
||||
if isinstance(v, int):
|
||||
new_config[k] = helpers.cast_to_int(config.get(k, v))
|
||||
elif isinstance(v, list):
|
||||
|
|
|
@ -584,7 +584,7 @@ def set_notifier_config(notifier_id=None, agent_id=None, **kwargs):
|
|||
notifier_config = {k[len(config_prefix):]: kwargs.pop(k)
|
||||
for k in list(kwargs.keys()) if k.startswith(config_prefix)}
|
||||
|
||||
for cfg, val in list(notifier_config.items()):
|
||||
for cfg, val in notifier_config.items():
|
||||
# Check for a password config keys and a blank password from the HTML form
|
||||
if 'password' in cfg and val == ' ':
|
||||
# Get the previous password so we don't overwrite it with a blank value
|
||||
|
@ -788,7 +788,7 @@ class Notifier(object):
|
|||
return default
|
||||
|
||||
new_config = {}
|
||||
for k, v in list(default.items()):
|
||||
for k, v in default.items():
|
||||
if isinstance(v, int):
|
||||
new_config[k] = helpers.cast_to_int(config.get(k, v))
|
||||
elif isinstance(v, list):
|
||||
|
@ -1399,9 +1399,9 @@ class EMAIL(Notifier):
|
|||
user_emails_cc.update(emails)
|
||||
user_emails_bcc.update(emails)
|
||||
|
||||
user_emails_to = [{'value': k, 'text': v} for k, v in list(user_emails_to.items())]
|
||||
user_emails_cc = [{'value': k, 'text': v} for k, v in list(user_emails_cc.items())]
|
||||
user_emails_bcc = [{'value': k, 'text': v} for k, v in list(user_emails_bcc.items())]
|
||||
user_emails_to = [{'value': k, 'text': v} for k, v in user_emails_to.items()]
|
||||
user_emails_cc = [{'value': k, 'text': v} for k, v in user_emails_cc.items()]
|
||||
user_emails_bcc = [{'value': k, 'text': v} for k, v in user_emails_bcc.items()]
|
||||
|
||||
return user_emails_to, user_emails_cc, user_emails_bcc
|
||||
|
||||
|
@ -3869,7 +3869,7 @@ def upgrade_config_to_db():
|
|||
|
||||
# Update the new config with the old config values
|
||||
notifier_config = {}
|
||||
for conf, val in list(notifier_default_config.items()):
|
||||
for conf, val in notifier_default_config.items():
|
||||
c_key = agent_config_key + '_' + config_key_overrides.get(agent, {}).get(conf, conf)
|
||||
notifier_config[agent + '_' + conf] = agent_config.get(c_key, val)
|
||||
|
||||
|
@ -3886,11 +3886,11 @@ def upgrade_config_to_db():
|
|||
|
||||
# Reverse the dict to {script: [actions]}
|
||||
script_actions = {}
|
||||
for k, v in list(action_scripts.items()):
|
||||
for k, v in action_scripts.items():
|
||||
if v: script_actions.setdefault(v, set()).add(k)
|
||||
|
||||
# Add a new script notifier for each script if the action was enabled
|
||||
for script, actions in list(script_actions.items()):
|
||||
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())})
|
||||
|
|
|
@ -1589,7 +1589,7 @@ class PmsConnect(object):
|
|||
if not platform and helpers.get_xml_attr(player_info, 'product') == 'DLNA':
|
||||
platform = 'DLNA'
|
||||
|
||||
platform_name = next((v for k, v in list(common.PLATFORM_NAMES.items()) if k in platform.lower()), 'default')
|
||||
platform_name = next((v for k, v in common.PLATFORM_NAMES.items() if k in platform.lower()), 'default')
|
||||
|
||||
player_details = {'ip_address': helpers.get_xml_attr(player_info, 'address').split('::ffff:')[-1],
|
||||
'ip_address_public': helpers.get_xml_attr(player_info, 'remotePublicAddress').split('::ffff:')[-1],
|
||||
|
@ -2375,7 +2375,7 @@ class PmsConnect(object):
|
|||
}
|
||||
children_results_list[media_type].append(children_output)
|
||||
|
||||
output = {'results_count': sum(len(s) for s in list(children_results_list.items())),
|
||||
output = {'results_count': sum(len(v) for k, v in children_results_list.items()),
|
||||
'results_list': children_results_list,
|
||||
}
|
||||
|
||||
|
|
|
@ -222,14 +222,14 @@ def mask_session_info(list_of_dicts, mask_metadata=True):
|
|||
|
||||
for d in list_of_dicts:
|
||||
if session_user_id and not (str(d.get('user_id')) == session_user_id or d.get('user') == session_user):
|
||||
for k, v in list(keys_to_mask.items()):
|
||||
for k, v in keys_to_mask.items():
|
||||
if k in d: d[k] = keys_to_mask[k]
|
||||
|
||||
if not mask_metadata:
|
||||
continue
|
||||
|
||||
if str(d.get('section_id','')) not in session_library_ids:
|
||||
for k, v in list(metadata_to_mask.items()):
|
||||
for k, v in metadata_to_mask.items():
|
||||
if k in d: d[k] = metadata_to_mask[k]
|
||||
continue
|
||||
|
||||
|
@ -253,7 +253,7 @@ def mask_session_info(list_of_dicts, mask_metadata=True):
|
|||
if d_content_rating in f_content_rating or set(d_labels).intersection(set(f_labels)):
|
||||
continue
|
||||
|
||||
for k, v in list(metadata_to_mask.items()):
|
||||
for k, v in metadata_to_mask.items():
|
||||
if k in d: d[k] = metadata_to_mask[k]
|
||||
|
||||
return list_of_dicts
|
|
@ -533,7 +533,7 @@ class Users(object):
|
|||
for item in result:
|
||||
# Rename Mystery platform names
|
||||
platform = common.PLATFORM_NAME_OVERRIDES.get(item['platform'], item['platform'])
|
||||
platform_name = next((v for k, v in list(common.PLATFORM_NAMES.items()) if k in platform.lower()), 'default')
|
||||
platform_name = next((v for k, v in common.PLATFORM_NAMES.items() if k in platform.lower()), 'default')
|
||||
|
||||
row = {'player_name': item['player'],
|
||||
'platform': platform,
|
||||
|
@ -799,7 +799,7 @@ class Users(object):
|
|||
result = {}
|
||||
|
||||
filters_list = {}
|
||||
for k, v in list(result.items()):
|
||||
for k, v in result.items():
|
||||
filters = {}
|
||||
|
||||
for f in v.split('|'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue