Skip to content

Commit 212d7a7

Browse files
committed
fixed a bug with the config file loading not working properly for dictionaries
1 parent 52e7645 commit 212d7a7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

main.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def error(error):
5757

5858
# opens the config file and loads the data
5959
def getConfigFile():
60+
# the default settings, don't use exampleConfig.json as people might change that
6061
defaultSettings = {
6162
"STEAM_API_KEY": "STEAM_API_KEY",
6263
"USER_IDS": "USER_ID",
@@ -98,21 +99,24 @@ def getConfigFile():
9899

99100
if exists(f"{dirname(__file__)}/config.json"):
100101
with open(f"{dirname(__file__)}/config.json", "r") as f:
101-
data = json.load(f)
102+
userSettings = json.load(f)
102103

103104
elif exists(f"{dirname(__file__)}/exampleconfig.json"):
104105
with open(f"{dirname(__file__)}/exampleconfig.json", "r") as f:
105-
data = json.load(f)
106+
userSettings = json.load(f)
106107

107108
else:
108109
error("Config file not found. Please read the readme and create a config file.")
109110
exit()
110111

111-
settings = defaultSettings
112-
for i in defaultSettings:
113-
if i in data:
114-
settings[i] = data[i]
115-
112+
113+
# if something isn't speficied in the user's config file, fill it in with data from the default settings
114+
settings = {**defaultSettings, **userSettings}
115+
for key, value in defaultSettings.items():
116+
if key in settings and isinstance(value, dict):
117+
settings[key] = {**value, **settings[key]}
118+
119+
116120
return settings
117121

118122
def getImageFromSGDB():

0 commit comments

Comments
 (0)