/usr/share/voctomix/voctocore/lib/config.py is in voctomix-core 1.0+git4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import os.path
import logging
from configparser import SafeConfigParser, DuplicateSectionError
from lib.args import Args
__all__ = ['Config']
Config = None
class VocConfigParser(SafeConfigParser):
def getlist(self, section, option):
option = self.get(section, option).strip()
if len(option) == 0:
return []
unfiltered = [x.strip() for x in option.split(',')]
return list(filter(None, unfiltered))
def add_section_if_missing(self, section):
try:
self.add_section(section)
except DuplicateSectionError:
pass
def load():
global Config
files = [
os.path.join(os.path.dirname(os.path.realpath(__file__)),
'../default-config.ini'),
os.path.join(os.path.dirname(os.path.realpath(__file__)),
'../config.ini'),
'/etc/voctomix/voctocore.ini',
'/etc/voctomix.ini', # deprecated
'/etc/voctocore.ini',
os.path.expanduser('~/.voctomix.ini'), # deprecated
os.path.expanduser('~/.voctocore.ini'),
]
if Args.ini_file is not None:
files.append(Args.ini_file)
Config = VocConfigParser()
readfiles = Config.read(files)
log = logging.getLogger('ConfigParser')
log.debug('considered config-files: \n%s',
"\n".join([
"\t\t" + os.path.normpath(file)
for file in files
]))
log.debug('successfully parsed config-files: \n%s',
"\n".join([
"\t\t" + os.path.normpath(file)
for file in readfiles
]))
if Args.ini_file is not None and Args.ini_file not in readfiles:
raise RuntimeError('explicitly requested config-file "{}" '
'could not be read'.format(Args.ini_file))
|