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


class ReadUserIni:
    @log_decorator
    def __init__(self, username):
        """获取用户配置ini文件的路径，并创建Configparser对象，在读取ini文件"""
        data_config_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data_config")
        # 获取用例存放数据的目录路径
        self.user_data_config_path = os.path.join(data_config_path, username)
        ini_path = os.path.join(self.user_data_config_path, "config.ini")
        self.conf = configparser.ConfigParser()
        self.conf.read(ini_path, encoding="utf-8")

    @log_decorator
    def get_file_path(self, key):
        """根据key，获取file节点下文件的路径"""
        return os.path.join(self.user_data_config_path, self.conf.get("file", key))

    @log_decorator
    def get_table_name(self, key):
        """根据key，获取工作表的名称"""
        return self.conf.get("table", key)


if __name__ == '__main__':
    ini = ReadUserIni("bpm")
    print(ini.get_file_path("case"))