fixed settings not creating if data folder not exists

This commit is contained in:
BarsTiger
2022-05-29 16:49:30 +03:00
parent 41523cd1c5
commit cb3c067d5e

View File

@@ -1,4 +1,5 @@
import json import json
import os
class Settings: class Settings:
@@ -16,8 +17,12 @@ class Settings:
@staticmethod @staticmethod
def fix() -> None: def fix() -> None:
with open("data/settings.json", "w") as file: try:
json.dump(Settings.default(), file) with open("data/settings.json", "w+") as file:
json.dump(Settings.default(), file)
except FileNotFoundError:
os.mkdir("data")
Settings.fix()
@staticmethod @staticmethod
def get_settings() -> dict: def get_settings() -> dict: