# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test67
# FileName:      read_ini.py
# Author:       lao_zhao
# Datetime:     2025/6/13 14:25
# Description:
# 
# ---------------------------------------------------------------------------
import configparser
import os.path

from APIAutoTest_v3 import log_decorator


class ReadSystemIni:
    @log_decorator
    def __init__(self):
        """获取ini文件路径，使用Configparser对象的read方法进行读取"""
        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("host", key)

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

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


if __name__ == '__main__':
    ini = ReadSystemIni()
    print(ini.get_user_data_name("user1"))