try and except create json files if missing

This commit is contained in:
Justin 2023-08-17 18:21:04 +08:00 committed by GitHub
parent f7f8fff458
commit b9007f6d5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -270,7 +270,8 @@ def index():
f.close() f.close()
except: except:
ipo_settings = {"feature": "IPO", "speed": "medium", "speed2": "medium", "animation": "down", "title": True, "symbols": ["No Data"]} ipo_settings = {"feature": "IPO", "speed": "medium", "speed2": "medium", "animation": "down", "title": True, "symbols": ["No Data"]}
with open('csv/ipo_settings.json', 'w') as f:
json.dump(ipo_settings, f)
try: try:
f = open('csv/forex_settings.json', 'r') f = open('csv/forex_settings.json', 'r')
forex_settings = json.load(f) forex_settings = json.load(f)
@ -358,7 +359,8 @@ def index():
f.close() f.close()
except: except:
economic_settings = {"feature": "Economic Calendar", "speed": "medium", "speed2": "medium", "animation": "up", "importance": "Med - High", "title": True, "timezone": "US/Eastern", "countries": ["United States"], "events": []} economic_settings = {"feature": "Economic Calendar", "speed": "medium", "speed2": "medium", "animation": "up", "importance": "Med - High", "title": True, "timezone": "US/Eastern", "countries": ["United States"], "events": []}
with open('csv/economic_settings.json', 'w') as f:
json.dump(economic_settings, f)
try: try:
f = open('csv/jokes_settings.json', 'r') f = open('csv/jokes_settings.json', 'r')
jokes_settings = json.load(f) jokes_settings = json.load(f)
@ -367,7 +369,8 @@ def index():
jokes_settings['categories'] = ['Any'] jokes_settings['categories'] = ['Any']
except: except:
jokes_settings = {"feature": "Jokes", "speed": "medium", "speed2": "medium", "animation": "up", "title": True, "safe": True, "categories": ["Any"], "blacklist": [], "amount": "5", "jokes": []} jokes_settings = {"feature": "Jokes", "speed": "medium", "speed2": "medium", "animation": "up", "title": True, "safe": True, "categories": ["Any"], "blacklist": [], "amount": "5", "jokes": []}
with open('csv/jokes_settings.json', 'w') as f:
json.dump(jokes_settings, f)
try: try:
f = open('csv/place_settings.json', 'r') f = open('csv/place_settings.json', 'r')
place_settings = json.load(f) place_settings = json.load(f)
@ -382,14 +385,16 @@ def index():
f.close() f.close()
except: except:
market_settings = {"feature": "Gainers, Losers, Active", "speed": "medium", "speed2": "medium", "animation": "up", "percent": True, "point": True, "logos": True, "chart": False, "title": True, "lohivol": False, "categories": ["Top Gainers", "Top Losers", "Most Active"], "gainers": {}, "losers": {}, "mostactive": {}} market_settings = {"feature": "Gainers, Losers, Active", "speed": "medium", "speed2": "medium", "animation": "up", "percent": True, "point": True, "logos": True, "chart": False, "title": True, "lohivol": False, "categories": ["Top Gainers", "Top Losers", "Most Active"], "gainers": {}, "losers": {}, "mostactive": {}}
with open('csv/market_settings.json', 'w') as f:
json.dump(market_settings, f)
try: try:
f = open('csv/sector_settings.json', 'r') f = open('csv/sector_settings.json', 'r')
sector_settings = json.load(f) sector_settings = json.load(f)
f.close() f.close()
except: except:
sector_settings = {"feature": "Sector Performance", "speed": "medium", "speed2": "medium", "animation": "up", "logos": True, "title": True, "sectors": ["Energy", "Financials", "Real Estate", "Technology"], "data": {}} sector_settings = {"feature": "Sector Performance", "speed": "medium", "speed2": "medium", "animation": "up", "logos": True, "title": True, "sectors": ["Energy", "Financials", "Real Estate", "Technology"], "data": {}}
with open('csv/sector_settings.json', 'w') as f:
json.dump(sector_settings, f)
try: try:
f = open('csv/scheduler.json','r') f = open('csv/scheduler.json','r')
scheduler_settings = json.load(f) scheduler_settings = json.load(f)