# -*- coding: utf-8 -*- # !/usr/bin/env python """ ------------------------------------------------- File Name: GetConfig.py Description : fetch config from config.ini Author : JHao date: 2016/12/3 ------------------------------------------------- Change Activity: 2016/12/3: get db property func ------------------------------------------------- """ __author__ = 'JHao' from Util.utilClass import LazyProperty class GetConfig(object): """ to get config from config.ini """ def __init__(self): pass @LazyProperty def db_type(self): return self.config_file.get('DB', 'type') @LazyProperty def db_name(self): return self.config_file.get('DB', 'name') @LazyProperty def db_host(self): return self.config_file.get('DB', 'host') @LazyProperty def db_port(self): return int(self.config_file.get('DB', 'port')) @LazyProperty def db_password(self): return self.config_file.get('DB', 'password') @LazyProperty def proxy_getter_functions(self): return self.config_file.options('ProxyGetter') @LazyProperty def host_ip(self): return self.config_file.get('API', 'ip') @LazyProperty def host_port(self): return int(self.config_file.get('API', 'port')) config = GetConfig() if __name__ == '__main__': gg = GetConfig() print(gg.db_type) print(gg.db_name) print(gg.db_host) print(gg.db_port) print(gg.proxy_getter_functions) print(gg.host_ip) print(gg.host_port) print(gg.db_password)