refactor: replace string concatenations with f-strings
All checks were successful
CI / test (push) Successful in 50s
All checks were successful
CI / test (push) Successful in 50s
This commit is contained in:
10
settings.py
10
settings.py
@@ -397,14 +397,14 @@ acceptable_targets = SETTINGS_INFO.keys() | {
|
||||
def comment_string(comment):
|
||||
result = ''
|
||||
for line in comment.splitlines():
|
||||
result += '# ' + line + '\n'
|
||||
result += f'# {line}\n'
|
||||
return result
|
||||
|
||||
|
||||
def save_settings(settings_dict):
|
||||
with open(settings_file_path, 'w', encoding='utf-8') as file:
|
||||
for setting_name, setting_info in SETTINGS_INFO.items():
|
||||
file.write(comment_string(setting_info['comment']) + setting_name + ' = ' + repr(settings_dict[setting_name]) + '\n\n')
|
||||
file.write(f"{comment_string(setting_info['comment'])}{setting_name} = {repr(settings_dict[setting_name])}\n\n")
|
||||
|
||||
|
||||
def add_missing_settings(settings_dict):
|
||||
@@ -481,7 +481,7 @@ upgrade_functions = {
|
||||
|
||||
|
||||
def log_ignored_line(line_number, message):
|
||||
print('WARNING: Ignoring settings.txt line ' + str(line_number) + ' (' + message + ')')
|
||||
print(f'WARNING: Ignoring settings.txt line {line_number} ({message})')
|
||||
|
||||
|
||||
if os.path.isfile("settings.txt"):
|
||||
@@ -535,7 +535,7 @@ else:
|
||||
continue
|
||||
|
||||
if target.id not in acceptable_targets:
|
||||
log_ignored_line(node.lineno, target.id + " is not a valid setting")
|
||||
log_ignored_line(node.lineno, f"{target.id} is not a valid setting")
|
||||
continue
|
||||
|
||||
if type(node.value) not in attributes:
|
||||
@@ -645,6 +645,6 @@ def settings_page():
|
||||
for func, old_value, value in to_call:
|
||||
func(old_value, value)
|
||||
|
||||
return flask.redirect(util.URL_ORIGIN + '/settings', 303)
|
||||
return flask.redirect(f'{util.URL_ORIGIN}/settings', 303)
|
||||
else:
|
||||
flask.abort(400)
|
||||
|
||||
Reference in New Issue
Block a user