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>
This commit is contained in:
Lukas Fleischer 2016-08-03 20:21:40 +02:00
parent 2915abb9d3
commit 2f5f5583be
5 changed files with 32 additions and 18 deletions

View file

@ -1,11 +1,10 @@
#!/usr/bin/python3
import configparser
import shlex
import os
import re
import sys
import config
import db
@ -24,9 +23,6 @@ def format_command(env_vars, command, ssh_opts, ssh_key):
return msg
config = configparser.RawConfigParser()
config.read(os.path.dirname(os.path.realpath(__file__)) + "/../conf/config")
valid_keytypes = config.get('auth', 'valid-keytypes').split()
username_regex = config.get('auth', 'username-regex')
git_serve_cmd = config.get('auth', 'git-serve-cmd')