配置文件不进版本库

pull/41/head
John Smith 4 years ago
parent 8aa80fadd3
commit 2df316b81c

@ -17,5 +17,5 @@ README.md
# runtime data
data/*
!data/config.ini
!data/config.example.ini
log/*

@ -7,7 +7,10 @@ from typing import *
logger = logging.getLogger(__name__)
CONFIG_PATH = os.path.join('data', 'config.ini')
CONFIG_PATH_LIST = [
os.path.join('data', 'config.ini'),
os.path.join('data', 'config.example.ini')
]
_config: Optional['AppConfig'] = None
@ -21,8 +24,16 @@ def init():
def reload():
config_path = ''
for path in CONFIG_PATH_LIST:
if os.path.exists(path):
config_path = path
break
if config_path == '':
return False
config = AppConfig()
if not config.load(CONFIG_PATH):
if not config.load(config_path):
return False
global _config
_config = config

@ -1,3 +1,6 @@
# 如果要修改配置可以复制此文件并重命名为“config.ini”再修改
# If you want to modify the configuration, copy this file and rename it to "config.ini" and edit
[app]
# 数据库配置见https://docs.sqlalchemy.org/en/13/core/engines.html#database-urls
# See https://docs.sqlalchemy.org/en/13/core/engines.html#database-urls
Loading…
Cancel
Save