mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Introduce a new environment variable that can be used to specify the path to an aurweb configuration file. If the environment variable is unset, the default search path is used. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
31 lines
659 B
Python
31 lines
659 B
Python
import configparser
|
|
import os
|
|
|
|
_parser = None
|
|
|
|
|
|
def _get_parser():
|
|
global _parser
|
|
|
|
if not _parser:
|
|
_parser = configparser.RawConfigParser()
|
|
if 'AUR_CONFIG' in os.environ:
|
|
path = os.environ.get('AUR_CONFIG')
|
|
else:
|
|
relpath = "/../conf/config"
|
|
path = os.path.dirname(os.path.realpath(__file__)) + relpath
|
|
_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)
|