forked from ancoka/hw_seckill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
24 lines (19 loc) · 785 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
# !/usr/bin/python
from configparser import ConfigParser
class Config:
def __init__(self, filename, encoding="utf-8"):
self.filename = filename
self.encoding = encoding
self.config = ConfigParser()
self.config.read(filename, encoding)
def get(self, section, option, default_value=None):
if default_value is None:
return self.config.get(section, option)
else:
return self.config.get(section, option, fallback=default_value)
def getboolean(self, section, option, default_value=None):
if default_value is None:
return self.config.getboolean(section, option)
else:
return self.config.getboolean(section, option, fallback=default_value)