read_yaml.py 492 B

12345678910111213141516171819
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. @author: Deepcold
  5. @file: read_yaml.py
  6. @time: 2019/8/19 15:45
  7. """
  8. import os
  9. import yaml
  10. from bin.utils.covert_dict_object import dict_to_object
  11. from config import SOURCE_ROOT
  12. def read_yaml(file_name):
  13. yaml_path = os.path.join(SOURCE_ROOT, "properties", file_name)
  14. with open(yaml_path, encoding="utf8") as f:
  15. config_text = yaml.load(f.read(), Loader=yaml.FullLoader)
  16. config = dict_to_object(config_text)
  17. return config