diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2016-09-20 20:18:24 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2016-09-29 22:07:06 +0200 |
commit | dc3fd60715a5b17b9542ec888c6eaeb14c284e2b (patch) | |
tree | 18d9f17b8d582409f0db55ee32fc5efa674aaa2e /aurweb/config.py | |
parent | 1946486a67d6085318e00c753d341ab05d12904c (diff) | |
download | aur-dc3fd60715a5b17b9542ec888c6eaeb14c284e2b.tar.gz aur-dc3fd60715a5b17b9542ec888c6eaeb14c284e2b.tar.xz |
Use setuptools to install Python modules
Instead of using relative imports, add support for installing the config
and db Python modules to a proper location using setuptools. Change all
git-interface scripts to access those modules from the search path.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'aurweb/config.py')
-rw-r--r-- | aurweb/config.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/aurweb/config.py b/aurweb/config.py new file mode 100644 index 00000000..aac188b1 --- /dev/null +++ b/aurweb/config.py @@ -0,0 +1,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) |