From 9fd9dadbc137c024bb9102b251f278d9285b5e35 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Sun, 23 Apr 2023 21:47:08 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=9F=9F=E5=90=8D=20-=20=E5=A2=9E=E5=8A=A0=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=8A=A5=E9=94=99=E5=9F=9F=E5=90=8D=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=20#195=20-=20=E4=BF=AE=E5=A4=8D=20Dev-debug=20=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E7=9A=84=E9=94=99=E8=AF=AF=20#192=20-=20=E9=87=8D?= =?UTF-8?q?=E5=81=9A=E9=87=8D=E5=91=BD=E5=90=8D=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=90=88=E9=9B=86=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E6=96=87=E4=BB=B6=E5=A4=B9=E5=86=85=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D=EF=BC=8C=E6=94=AF=E6=8C=81=E5=AD=97=E5=B9=95?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E3=80=82=20-=20Fix=20pytest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module/conf/config.py | 15 +++++++++++++-- src/module/models/config.py | 14 +++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/module/conf/config.py b/src/module/conf/config.py index 9570512b..1e5826f4 100644 --- a/src/module/conf/config.py +++ b/src/module/conf/config.py @@ -52,10 +52,21 @@ def env_to_config() -> Config: if os.path.isdir("config") and VERSION == "DEV_VERSION": CONFIG_PATH = "config/config_dev.json" - settings = load_config_from_file(CONFIG_PATH) - print(dict(settings)) + if os.path.isfile(CONFIG_PATH): + settings = load_config_from_file(CONFIG_PATH) + else: + settings = env_to_config() + save_config_to_file(settings, CONFIG_PATH) elif os.path.isdir("config") and VERSION != "DEV_VERSION": CONFIG_PATH = "config/config.json" + if os.path.isfile(CONFIG_PATH): + settings = load_config_from_file(CONFIG_PATH) + else: + settings = env_to_config() + save_config_to_file(settings, CONFIG_PATH) +else: + settings = Config() + diff --git a/src/module/models/config.py b/src/module/models/config.py index a4d5a6b7..b2d0a62b 100644 --- a/src/module/models/config.py +++ b/src/module/models/config.py @@ -60,10 +60,10 @@ class Notification(BaseModel): class Config(BaseModel): data_version: float = Field(4.0, description="Data version") - program: Program - downloader: Downloader - rss_parser: RSSParser - bangumi_manage: BangumiManage - debug: Debug - proxy: Proxy - notification: Notification + program: Program = Program() + downloader: Downloader = Downloader() + rss_parser: RSSParser = RSSParser() + bangumi_manage: BangumiManage = BangumiManage() + debug: Debug = Debug() + proxy: Proxy = Proxy() + notification: Notification = Notification()