# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test66
# FileName:      read_system_ini.py
# Author:       lao_zhao
# Datetime:     2025/5/9 11:21
# Description:
# 
# ---------------------------------------------------------------------------
import configparser
import os
from APIAutoTest_v3 import log_decorator


class ReadSystemIni:
    @log_decorator
    def __init__(self):
        """获取系统配置ini文件的路径，并创建Configparser对象，在读取ini文件"""
        data_config_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data_config")
        ini_path = os.path.join(data_config_path, "system_config.ini")
        self.conf = configparser.ConfigParser()
        self.conf.read(ini_path, encoding="utf-8")

    @log_decorator
    def get_host(self, key):
        """根据key，获取被测系统的域名"""
        return self.conf.get("url", key)

    @log_decorator
    def get_sql_connect_msg(self, key):
        """根据key，获取数据库的链接信息"""
        return self.conf.get("sql", key)

    @log_decorator
    def get_username(self, key):
        """根据key，获取用户存放数据的目录名称"""
        return self.conf.get("user", key)


if __name__ == '__main__':
    ini = ReadSystemIni()
    print(ini.get_host("host"))