# -*- coding: utf-8 -*-
# 配置文件yaml解析类
# 作者: 陈磊
# 时间: 2019-10-21

import yaml
import os

from WorkUtils.UtilsLog import UtilsLog
from WorkBase import WorkBase


class UtilsYaml:
    def __init__(self, filename):
        self.log = UtilsLog()
        self.log.info("调用配置文件yaml解析类")
        self.log.info(self.__class__)

        self.filename = filename

    def read(self):
        self.log.debug("打开yaml文件")
        yaml_file = os.path.join(WorkBase().yaml_path + self.filename)
        self.log.debug(yaml_file)
        with open(yaml_file, "rb") as f:
            info = f.read()
        r_info = yaml.load(info)
        self.log.debug("成功解析yaml文件...")
        self.log.debug(r_info)
        return r_info
