From 78c30de2f414f4fe9aa6b5e19626b2ce49eeb69c Mon Sep 17 00:00:00 2001 From: msincenselee Date: Thu, 27 Feb 2020 11:20:57 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=A2=9E=E5=BC=BA]=20=E8=AF=BB=E5=8F=96json?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6=EF=BC=8C=E6=A0=B9=E6=8D=AE=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=80=89=E6=8B=A9=E6=98=AF=E5=90=A6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E4=BF=9D=E5=AD=98json=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/setting.py | 2 +- vnpy/trader/utility.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vnpy/trader/setting.py b/vnpy/trader/setting.py index 1dd8b0ff..77f07ece 100644 --- a/vnpy/trader/setting.py +++ b/vnpy/trader/setting.py @@ -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 = ""): diff --git a/vnpy/trader/utility.py b/vnpy/trader/utility.py index fb7daa95..dc23c702 100644 --- a/vnpy/trader/utility.py +++ b/vnpy/trader/utility.py @@ -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,7 +257,8 @@ def load_json(filename: str): data = json.load(f) return data else: - save_json(filename, {}) + if auto_save: + save_json(filename, {}) return {}