zoukankan      html  css  js  c++  java
  • python

    # -*- coding:utf-8 -*-
    
    '''
    @project: ApiAutoTest
    @author: Jimmy
    @file: read_config.py
    @ide: PyCharm Community Edition
    @time: 2018-12-21 13:53
    @blog: https://www.cnblogs.com/gotesting/
    
    '''
    
    
    import configparser
    import os
    from Common import contants
    
    # 创建实例
    # 加载配置文件
    # 根据section option获取值
    
    
    class ReadConfig:
    
        # 初始化函数:实例化conf对象,读取传入的配置文件
        def __init__(self):
            self.conf = configparser.ConfigParser()
            file = os.path.join(contants.conf_dir,'global.conf')
            self.conf.read(file)
            if self.get_config_boolean('switch','button'):
                test_conf = os.path.join(contants.conf_dir,'test_env.conf')
                self.conf.read(test_conf)
            else:
                online_conf = os.path.join(contants.conf_dir,'online_env.conf')
                self.conf.read(online_conf)
    
        def get_config_str(self,section,option):
            return self.conf.get(section,option)
    
        def get_config_boolean(self,section,option):
            return self.conf.getboolean(section,option)
    
        def get_config_int(self,section,option):
            return self.conf.getint(section,option)
    
        def get_config_float(self,section,option):
            return self.conf.getfloat(section,option)
  • 相关阅读:
    692. Top K Frequent Words
    659. Split Array into Consecutive Subsequences
    hdu5015矩阵快速幂
    codefroces 450B矩阵快速幂
    ural Ambitious Experiment 树状数组
    poj3254 状态压缩dp
    poj2686 状压dp入门
    hdu4763 kmp
    hdu4847 kmp
    hdu3294 manacher
  • 原文地址:https://www.cnblogs.com/gotesting/p/10156139.html
Copyright © 2011-2022 走看看