mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add a new module that automatically locates the configuration file and provides methods to obtain the values of configuration options. Use the new module instead of ConfigParser everywhere. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
27 lines
524 B
Python
27 lines
524 B
Python
import configparser
|
|
import os
|
|
|
|
_parser = None
|
|
|
|
|
|
def _get_parser():
|
|
global _parser
|
|
|
|
if not _parser:
|
|
_parser = configparser.RawConfigParser()
|
|
path = os.path.dirname(os.path.realpath(__file__)) + "/../conf/config"
|
|
_parser.read(path)
|
|
|
|
return _parser
|
|
|
|
|
|
def get(section, option):
|
|
return _get_parser().get(section, option)
|
|
|
|
|
|
def getboolean(section, option):
|
|
return _get_parser().getboolean(section, option)
|
|
|
|
|
|
def getint(section, option):
|
|
return _get_parser().getint(section, option)
|