Yet Another WebIOPi+
 All Classes Namespaces Files Functions Variables Macros Pages
config.py
Go to the documentation of this file.
1 from webiopi.utils.version import PYTHON_MAJOR
2 
3 if PYTHON_MAJOR >= 3:
4  import configparser as parser
5 else:
6  import ConfigParser as parser
7 
8 class Config():
9 
10  def __init__(self, configfile=None):
11  config = parser.ConfigParser()
12  config.optionxform = str
13  if configfile != None:
14  config.read(configfile)
15  self.config = config
16 
17  def get(self, section, key, default):
18  if self.config.has_option(section, key):
19  return self.config.get(section, key)
20  return default
21 
22  def getboolean(self, section, key, default):
23  if self.config.has_option(section, key):
24  return self.config.getboolean(section, key)
25  return default
26 
27  def getint(self, section, key, default):
28  if self.config.has_option(section, key):
29  return self.config.getint(section, key)
30  return default
31 
32  def items(self, section):
33  if self.config.has_section(section):
34  return self.config.items(section)
35  return {}