[增强] 读取json文件时,根据参数选择是否自动保存json文件

This commit is contained in:
msincenselee 2020-02-27 11:20:57 +08:00
parent 2811ab1068
commit 78c30de2f4
2 changed files with 4 additions and 3 deletions

View File

@ -36,7 +36,7 @@ SETTINGS = {
# Load global setting from json file.
SETTING_FILENAME = "vt_setting.json"
SETTINGS.update(load_json(SETTING_FILENAME))
SETTINGS.update(load_json(SETTING_FILENAME, auto_save=False))
def get_settings(prefix: str = ""):

View File

@ -246,7 +246,7 @@ def get_icon_path(filepath: str, ico_name: str):
return str(icon_path)
def load_json(filename: str):
def load_json(filename: str, auto_save : bool = True):
"""
Load data from json file in temp path.
"""
@ -257,6 +257,7 @@ def load_json(filename: str):
data = json.load(f)
return data
else:
if auto_save:
save_json(filename, {})
return {}