save globalstocks settings

This commit is contained in:
Justin 2023-09-25 22:08:25 +08:00 committed by GitHub
parent 947d8df292
commit b08fd37013
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -932,6 +932,8 @@ def save():
save_worldclock_settings(input_settings)
elif feature == 'Inspirational Quotes':
save_quotes_settings(input_settings)
elif feature == 'Global Stocks':
save_globalstocks_settings(input_settings)
elif feature in ['Custom GIFs', 'Custom Images']:
images = request.files
@ -1808,6 +1810,44 @@ def save_quotes_settings(input_settings):
json.dump(current_settings, f)
def save_globalstocks_settings(input_settings):
filename = 'globalstocks_settings.json'
try:
f = open('csv/' + filename, 'r')
current_settings = json.load(f)
f.close()
except:
current_settings = {"feature": "Global Stocks", "speed": "medium", "speed2": "medium", "animation": "continuous", "percent": True, "point": True, "logos": True, "chart": False, "title": True, "lohivol": True, "display_name": False, "symbols": []}
current_settings['speed'] = input_settings['speed'].lower()
current_settings['speed2'] = input_settings['speed2'].lower()
current_settings['animation'] = input_settings['animation'].lower()
current_settings['percent'] = input_settings['percent']
current_settings['point'] = input_settings['point']
current_settings['logos'] = input_settings['logos']
current_settings['title'] = input_settings['title']
current_settings['chart'] = input_settings['chart']
current_settings['lohivol'] = input_settings['lohivol']
current_settings['display_name'] = input_settings['display_name']
current_settings = combine_dict(current_settings, input_settings['symbols'], 'symbols')
try:
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
except:
with open('csv/globalstocks_settings.json', 'w') as f:
json.dump(current_settings, f)
if any([current_settings['symbols'][k] == [] for k in input_settings['symbols']]):
f = open('csv/last_updates.json', 'r')
last_updates = json.load(f)
f.close()
last_updates['globalstocks']['force'] = True
f = open('csv/last_updates.json', 'w')
json.dump(last_updates, f)
f.close()
def save_place_settings(input_settings):
filename = 'place_settings.json'
try: