Archived
将数据库合并并添加了配置文件
This commit is contained in:
11 files changed
+313
-254
No files matched your search
+53
-1
@@ -3,4 +3,56 @@
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/23
|
||||
# @File Name: settings.py
|
||||
# @File Name: settings.py
|
||||
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
class Settings:
|
||||
def __init__(self):
|
||||
self.__setting_file = './bin/conf/config.yml'
|
||||
with open(self.__setting_file, encoding='utf-8') as fp:
|
||||
self.data = yaml.load(fp.read(), Loader=yaml.Loader)
|
||||
self.__servers = self.data['servers']
|
||||
self.__database = self.data['database']
|
||||
|
||||
@property
|
||||
def host(self) -> str:
|
||||
"""
|
||||
应用地址
|
||||
:return:
|
||||
"""
|
||||
return self.__servers['host']
|
||||
|
||||
@property
|
||||
def port(self) -> str:
|
||||
"""
|
||||
应用端口
|
||||
:return:
|
||||
"""
|
||||
return self.__servers['port']
|
||||
|
||||
@property
|
||||
def type(self) -> str:
|
||||
"""
|
||||
数据库类型
|
||||
:return:
|
||||
"""
|
||||
return self.__database['type']
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
"""
|
||||
数据库路径
|
||||
:return:
|
||||
"""
|
||||
return self.__database['sqlite']['path']
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""
|
||||
数据库名称
|
||||
:return:
|
||||
"""
|
||||
return self.__database['sqlite']['path'].split('/')[-1]
|
||||
Reference in New Issue
Block a user