-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.py
41 lines (29 loc) · 894 Bytes
/
config.py
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
32
33
34
35
36
37
38
39
40
41
'''
That module wraps access to configuration file.
Usage:
import config
print(config.DB_SCHEMA)
'''
import configparser
from os.path import expanduser
def get_config():
'''
Returns the configuration file as a ConfigParser object
'''
cfg = configparser.ConfigParser(interpolation=None)
path = expanduser('~/.pgsf')
assert cfg.read(path), "Could not read " + path
return cfg
def get_section(name='DEFAULT'):
'''
Returns the ConfigParser section
'''
return __cfg[name]
__cfg = get_config()
DB_SCHEMA = __cfg['postgresql'].get('schema', None)
DB_QUOTE_NAMES = __cfg['postgresql'].getboolean('quote_name', False)
GRANT_TO = __cfg['postgresql'].get('grant_to', None)
JOB_DIR = __cfg['DEFAULT']['job_dir']
LOGFILE = __cfg['DEFAULT']['log_file']
LOGFORMAT = __cfg['DEFAULT']['log_format']
LOGLEVEL = __cfg['DEFAULT'].getint('log_level')