Music-Library/config.py
2024-04-15 13:21:43 +00:00

31 lines
827 B
Python

import json, os
class configManager():
def __init__(self):
print("Loading config...")
self.config = {
"config_version": 1,
"music_folder": "C:/Users/username/Music",
}
def setConfigTemplate(self, template):
self.config = template
def load_config(self):
# load config
if os.path.exists("config.json"):
with open("config.json", "r") as config_file:
self.config = json.load(config_file)
else:
self.save_config()
def save_config(self):
# save config
with open("config.json", "w") as config_file:
json.dump(self.config, config_file)
def get(self, key):
return self.config.get(key, None)
def set(self, key, value):
self.config[key] = value