首页 > Web开发 > 详细

UI自动化web端框架config.py代码

时间:2018-07-05 14:34:03      阅读:173      评论:0      收藏:0      [点我收藏+]
import json
from lib.core.path import CONFPATH
class ConfigType(object):
MYSQL = ‘mysql‘
REDIS = ‘redis‘

class Config(object):
def __init__(self):
self.config = {}

def make(self):
# mysql 配置信息
self.config[ConfigType.MYSQL] = {}
self.config[ConfigType.MYSQL][‘host‘] = ‘127.0.0.1‘
self.config[ConfigType.MYSQL][‘port‘] = 3306
self.config[ConfigType.MYSQL][‘user‘] = ‘sky‘
self.config[ConfigType.MYSQL][‘passwd‘] = ‘123456‘
self.config[ConfigType.MYSQL][‘db‘] = ‘ssj‘
self.config[ConfigType.MYSQL][‘charset‘] = ‘utf8‘

# redis 配置信息
self.config[ConfigType.MYSQL] = {}
self.config[ConfigType.MYSQL][‘host‘] = ‘127.0.0.1‘
self.config[ConfigType.MYSQL][‘port‘] = 3306
self.config[ConfigType.MYSQL][‘user‘] = ‘sky‘
self.config[ConfigType.MYSQL][‘passwd‘] = ‘123456‘
self.config[ConfigType.MYSQL][‘db‘] = ‘ssj‘
self.config[ConfigType.MYSQL][‘charset‘] = ‘utf8‘

fw = open(CONFPATH,‘w‘)
fw.write(json.dumps(self.config))
fw.flush()
fw.close()

def read(self,config):
fr = open(CONFPATH)
data = json.load(fr)
if config == ConfigType.MYSQL:
return data[ConfigType.MYSQL]
elif config == ConfigType.REDIS:
return data[ConfigType.REDIS]

if __name__ == ‘__main__‘:
Config().make()
print(Config().read(ConfigType.MYSQL))

UI自动化web端框架config.py代码

原文:https://www.cnblogs.com/laosun0204/p/9267966.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!