You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import os
|
|
|
|
import configparser
|
|
|
|
|
|
|
|
|
|
|
|
class Config(object):
|
|
|
|
def __init__(self, config_file='config.ini'):
|
|
|
|
self._path = os.path.join(os.getcwd(), config_file)
|
|
|
|
if not os.path.exists(self._path):
|
|
|
|
raise FileNotFoundError("No such file: config.ini")
|
|
|
|
self._config = configparser.ConfigParser()
|
|
|
|
self._config.read(self._path, encoding='utf-8-sig')
|
|
|
|
self._configRaw = configparser.RawConfigParser()
|
|
|
|
self._configRaw.read(self._path, encoding='utf-8-sig')
|
|
|
|
|
|
|
|
def get(self, section, name):
|
|
|
|
return self._config.get(section, name)
|
|
|
|
|
|
|
|
def getRaw(self, section, name):
|
|
|
|
return self._configRaw.get(section, name)
|
|
|
|
|
|
|
|
def setMode(self, mode=''):
|
|
|
|
self.mode = mode
|
|
|
|
|
|
|
|
def getMode(self):
|
|
|
|
return self.mode
|
|
|
|
|
|
|
|
|
|
|
|
global_config = Config()
|