diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2016-08-03 20:21:40 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2016-08-05 12:05:22 +0200 |
commit | 2f5f5583bec2a0a04424d6bedd763855f308bce6 (patch) | |
tree | 11728e9e0405899f1aab60af5daec7aa3e99a0c7 /git-interface/config.py | |
parent | 2915abb9d35308150ec107c5f4664e116daaf1de (diff) |
git-interface: Factor out configuration file parsing
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>
Diffstat (limited to 'git-interface/config.py')
-rw-r--r-- | git-interface/config.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/git-interface/config.py b/git-interface/config.py new file mode 100644 index 0000000..cd6495b --- /dev/null +++ b/git-interface/config.py @@ -0,0 +1,27 @@ +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) |