From 50ee56b1582aa1d2ce8517541ad4791684b8432c Mon Sep 17 00:00:00 2001 From: harry Date: Fri, 29 Mar 2024 10:16:24 +0800 Subject: [PATCH] if config.toml doesn't exist, copy the example config --- app/config/config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/config/config.py b/app/config/config.py index f4866ed..14322bd 100644 --- a/app/config/config.py +++ b/app/config/config.py @@ -5,6 +5,13 @@ from loguru import logger root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) config_file = f"{root_dir}/config.toml" +if not os.path.isfile(config_file): + example_file = f"{root_dir}/config.example.toml" + if os.path.isfile(example_file): + import shutil + shutil.copyfile(example_file, config_file) + logger.info(f"copy config.example.toml to config.toml") + logger.info(f"load config from file: {config_file}") with open(config_file, mode="rb") as fp: