read_conf.py 666 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. # @Time : 2024/5/17
  3. # @Author : 魏志亮
  4. import os
  5. import yaml
  6. def read_yaml_file(filename, type):
  7. path = os.path.abspath(__file__)
  8. for i in range(3):
  9. path = os.path.dirname(path)
  10. with open(path + os.sep + "config_files" + os.sep + filename + os.sep + type + ".yaml", 'r', encoding='utf-8') as f:
  11. return yaml.safe_load(f)
  12. def read_param_from_config(conf, type, default_value=None):
  13. if type in conf:
  14. return conf[type]
  15. else:
  16. return default_value
  17. if __name__ == '__main__':
  18. yaml_files = os.listdir("../../config_files")
  19. types = ['second', 'minute']
  20. print(yaml_files)