summaryrefslogtreecommitdiffstats
path: root/aurweb/config.py
blob: aac188b1d7c98daba7c0ff9db0d4ef0cd45987fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)