From b2e6cdde266260a525ef80147dacbcd2ada3a985 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Mon, 31 Oct 2022 15:17:09 -0400 Subject: Better organization of code --- settings.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'settings.py') diff --git a/settings.py b/settings.py index c5ed5c7..e94dbe2 100644 --- a/settings.py +++ b/settings.py @@ -1,14 +1,14 @@ import json +from logging import exception -settingsJSON = open('settings.json') +def getSettings(settingSection): + try: + settingsJSON = open("settings.json", "r") + except FileNotFoundError: + exception("settings.json not found make sure it exists in this folder") -settings = json.load(settingsJSON) + settings = json.load(settingsJSON) + settingsJSON.close() -calendars = settings["calendars"] -weather = settings["weather"] -news = settings["news"] -modules = settings["modules"] -general = settings["general"] -lineWidth = settings["general"]["Line Width"] + return settings[settingSection] -settingsJSON.close() -- cgit v1.2.3