# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test
# FileName:      read_basic_ini.py
# Author:       mwx
# Datetime:     2024/11/5 19:09
# Description:
# 
# ---------------------------------------------------------------------------
import configparser
import logging
import os

from Interface_automation.APIAutoText_v3_1_1 import log


class ReadBasicIni:
    def __init__(self):
        file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)),"data_cofig")
        self.ini_path = os.path.join(file_path,"basic_config.ini")
        self.conf = configparser.ConfigParser()
        self.conf.read( self.ini_path,encoding="utf-8")
    def get_host(self,key):
        log.info(f"获取host节点下的信息，传入的键为{key}")
        try:
            return self.conf.get("host",key)
        except Exception as e:
            log.error(f"获取host节点下的域名，传入的key为{key}，错误类型为{type(e)}")
            raise e

    def get_sql(self,key):
        log.info(f"获取sql节点下的信息，传入的键为{key}")
        try:
            return self.conf.get("sql",key)
        except Exception as e:
            log.error(f"获取sql节点下的信息，传入{key},获取数据失败，错误类型为{type(e)}")
            raise e

if __name__ == '__main__':
    r = ReadBasicIni()
    print(r.get_sql("host"))
