[增强] 读取json文件时,根据参数选择是否自动保存json文件
This commit is contained in:
parent
2811ab1068
commit
78c30de2f4
@ -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 = ""):
|
||||
|
@ -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 {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user