-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigFunctions.py
More file actions
34 lines (26 loc) · 975 Bytes
/
ConfigFunctions.py
File metadata and controls
34 lines (26 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
configLoc = "./config.json"
baseMusicLoc = "./Music"
# this could be changed out later to some kind of object or have an object passed after which it would be converted and written to file
def updateConfig(volume, musicFolder, configLoc=configLoc):
config ={
"Volume": volume,
"MusicFolder": musicFolder
}
with open(configLoc, "w") as file:
json.dump(config, file)
def getSettings(configLoc=configLoc):
# This can be updated later with more settings pretty easily
try:
with open(configLoc) as file:
config = json.load(file)
except:
updateConfig(10, baseMusicLoc)
return 10, baseMusicLoc
volume = config["Volume"]
musicLoc = config["MusicFolder"]
if volume == '' or musicLoc == '':
volume = 10 if volume == '' else volume
musicLoc = baseMusicLoc if musicLoc == '' else musicLoc
updateConfig(volume, musicLoc)
return volume, musicLoc