Run futurize --stage2

This commit is contained in:
JonnyWong16 2019-11-23 19:16:51 -08:00
parent ab6196589b
commit 597cc9fe29
12 changed files with 30 additions and 30 deletions

View file

@ -502,7 +502,7 @@ class ActivityProcessor(object):
if state:
values['state'] = state
for k, v in kwargs.items():
for k, v in list(kwargs.items()):
values[k] = v
keys = {'session_key': session_key}

View file

@ -274,10 +274,10 @@ class API2(object):
config = {}
# Truthify the dict
for k, v in conf.items():
for k, v in list(conf.items()):
if isinstance(v, dict):
d = {}
for kk, vv in v.items():
for kk, vv in list(v.items()):
if vv == '0' or vv == '1':
d[kk] = bool(vv)
else:

View file

@ -693,8 +693,8 @@ class Config(object):
""" Add tokens and passwords to blacklisted words in logger """
blacklist = set()
for key, subkeys in self._config.items():
for subkey, value in subkeys.items():
for key, subkeys in list(self._config.items()):
for subkey, value in list(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())

View file

@ -664,7 +664,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 common.PLATFORM_NAMES.items() if k in platform.lower()), 'default')
platform_name = next((v for k, v in list(common.PLATFORM_NAMES.items()) if k in platform.lower()), 'default')
row = {'total_plays': item['total_plays'],
'total_duration': item['total_duration'],
@ -994,7 +994,7 @@ class DataFactory(object):
'pre_tautulli': pre_tautulli
}
stream_output = {k: v or '' for k, v in stream_output.items()}
stream_output = {k: v or '' for k, v in list(stream_output.items())}
return stream_output
def get_metadata_details(self, rating_key):
@ -1527,7 +1527,7 @@ class DataFactory(object):
# function to map rating keys pairs
def get_pairs(old, new):
pairs = {}
for k, v in old.items():
for k, v in list(old.items()):
if k in new:
pairs.update({v['rating_key']: new[k]['rating_key']})
if 'children' in old[k]:
@ -1542,7 +1542,7 @@ class DataFactory(object):
if mapping:
logger.info("Tautulli DataFactory :: Updating metadata in the database.")
for old_key, new_key in mapping.items():
for old_key, new_key in list(mapping.items()):
metadata = pms_connect.get_metadata_details(new_key)
if metadata:

View file

@ -338,7 +338,7 @@ def replace_all(text, dic, normalize=False):
if not text:
return ''
for i, j in dic.items():
for i, j in list(dic.items()):
if normalize:
try:
if sys.platform == 'darwin':
@ -567,7 +567,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 obj.items()}
return {k: sanitize(v) for k, v in list(obj.items())}
elif isinstance(obj, tuple):
return tuple(sanitize(list(obj)))
else:
@ -1182,7 +1182,7 @@ def traverse_map(obj, func):
elif isinstance(obj, dict):
new_obj = {}
for k, v in obj.items():
for k, v in list(obj.items()):
new_obj[traverse_map(k, func)] = traverse_map(v, func)
else:
@ -1207,7 +1207,7 @@ def mask_config_passwords(config):
cfg['value'] = ' '
elif isinstance(config, dict):
for cfg, val in config.items():
for cfg, val in list(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

View file

@ -220,7 +220,7 @@ def update_labels():
% section_id)
error_keys = set()
for rating_key, labels in key_mappings.items():
for rating_key, labels in list(key_mappings.items()):
try:
labels = ';'.join(labels)
monitor_db.action('UPDATE session_history_metadata SET labels = ? '
@ -547,7 +547,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 row.items():
for k,v in list(row.items()):
if k in searchable_columns and search_value in v.lower():
results.append(row)
break

View file

@ -61,7 +61,7 @@ def blacklist_config(config):
blacklist = set()
blacklist_keys = ['HOOK', 'APIKEY', 'KEY', 'PASSWORD', 'TOKEN']
for key, value in config.items():
for key, value in list(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)):

View file

@ -240,7 +240,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 email_config.items():
for cfg, val in list(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
@ -425,7 +425,7 @@ class Newsletter(object):
return default
new_config = {}
for k, v in default.items():
for k, v in list(default.items()):
if isinstance(v, int):
new_config[k] = helpers.cast_to_int(config.get(k, v))
elif isinstance(v, list):

View file

@ -598,7 +598,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 notifier_config.items():
for cfg, val in list(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
@ -802,7 +802,7 @@ class Notifier(object):
return default
new_config = {}
for k, v in default.items():
for k, v in list(default.items()):
if isinstance(v, int):
new_config[k] = helpers.cast_to_int(config.get(k, v))
elif isinstance(v, list):
@ -1413,9 +1413,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 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()]
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())]
return user_emails_to, user_emails_cc, user_emails_bcc
@ -3956,7 +3956,7 @@ def upgrade_config_to_db():
# Update the new config with the old config values
notifier_config = {}
for conf, val in notifier_default_config.items():
for conf, val in list(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)

View file

@ -1543,7 +1543,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 common.PLATFORM_NAMES.items() if k in platform.lower()), 'default')
platform_name = next((v for k, v in list(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],

View file

@ -221,14 +221,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 keys_to_mask.items():
for k, v in list(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 metadata_to_mask.items():
for k, v in list(metadata_to_mask.items()):
if k in d: d[k] = metadata_to_mask[k]
continue
@ -252,7 +252,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 metadata_to_mask.items():
for k, v in list(metadata_to_mask.items()):
if k in d: d[k] = metadata_to_mask[k]
return list_of_dicts

View file

@ -518,7 +518,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 common.PLATFORM_NAMES.items() if k in platform.lower()), 'default')
platform_name = next((v for k, v in list(common.PLATFORM_NAMES.items()) if k in platform.lower()), 'default')
row = {'player_name': item['player'],
'platform': platform,
@ -781,7 +781,7 @@ class Users(object):
result = {}
filters_list = {}
for k, v in result.items():
for k, v in list(result.items()):
filters = {}
for f in v.split('|'):