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.

RWUtils.py 441B

123456789101112131415
  1. # -*- coding: utf-8 -*-
  2. from json import loads
  3. from os.path import join
  4. from ruamel.yaml import safe_load
  5. def getConfigs(base_dir, file_path, read_type='yml'):
  6. path = join(base_dir, file_path)
  7. with open(path, 'r', encoding="utf-8") as f:
  8. if read_type == 'json':
  9. return loads(f.read())
  10. if read_type == 'yml':
  11. return safe_load(f)
  12. raise Exception('路径: %s未获取配置信息' % path)