import os import yaml from common import Constant # 从配置文件读取所有配置信息 def getConfigs(): print("开始读取配置文件,获取配置消息:", Constant.APPLICATION_CONFIG) applicationConfigPath = os.path.abspath(Constant.APPLICATION_CONFIG) if not os.path.exists(applicationConfigPath): raise Exception("未找到配置文件:{}".format(Constant.APPLICATION_CONFIG)) with open(applicationConfigPath, Constant.R, encoding=Constant.UTF_8) as f: file_content = f.read() content = yaml.load(file_content, yaml.FullLoader) if not content: raise Exception("配置项不能为空:{}".format(Constant.APPLICATION_CONFIG)) print("读取配置文件完成!") return content