You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 年之前
2 年之前
2 年之前
123456789101112131415161718
  1. import os
  2. import yaml
  3. from common import Constant
  4. # 从配置文件读取所有配置信息
  5. def getConfigs():
  6. print("开始读取配置文件,获取配置消息:", Constant.APPLICATION_CONFIG)
  7. applicationConfigPath = os.path.abspath(Constant.APPLICATION_CONFIG)
  8. if not os.path.exists(applicationConfigPath):
  9. raise Exception("未找到配置文件:{}".format(Constant.APPLICATION_CONFIG))
  10. with open(applicationConfigPath, Constant.R, encoding=Constant.UTF_8) as f:
  11. file_content = f.read()
  12. content = yaml.load(file_content, yaml.FullLoader)
  13. if not content:
  14. raise Exception("配置项不能为空:{}".format(Constant.APPLICATION_CONFIG))
  15. print("读取配置文件完成!")
  16. return content