if option in default_option isn't found, default value will be added to option.json

This commit is contained in:
raphael60650 2021-06-24 11:26:53 +02:00
parent 68c82393d6
commit b9abcd2919

View file

@ -7,6 +7,7 @@ default_option = {
"disable_download": False, "disable_download": False,
"del_track_after_conv": False, "del_track_after_conv": False,
"dont_check_for_update": False, "dont_check_for_update": False,
"dont_check_track_sha1": False,
"process_track": 8 "process_track": 8
} }
@ -22,3 +23,7 @@ def load_option(self):
if not(os.path.exists("./option.json")): if not(os.path.exists("./option.json")):
with open("./option.json", "w", encoding="utf-8") as f: json.dump(default_option, f, ensure_ascii=False) with open("./option.json", "w", encoding="utf-8") as f: json.dump(default_option, f, ensure_ascii=False)
with open("./option.json", encoding="utf-8") as f: self.option = json.load(f) with open("./option.json", encoding="utf-8") as f: self.option = json.load(f)
for option_key, option_value in default_option.items():
if not(option_key in self.option):
self.option[option_key] = option_value