aboutsummaryrefslogtreecommitdiff
path: root/voctocore/lib/config.py
blob: df0ff9a5e3e1e57e501738e0faa82bbd4148b679 (plain)
  1. import os.path
  2. import logging
  3. from configparser import SafeConfigParser
  4. from lib.args import Args
  5. __all__ = ['Config']
  6. def getlist(self, section, option):
  7. return [x.strip() for x in self.get(section, option).split(',')]
  8. SafeConfigParser.getlist = getlist
  9. files = [
  10. os.path.join(os.path.dirname(os.path.realpath(__file__)), '../default-config.ini'),
  11. os.path.join(os.path.dirname(os.path.realpath(__file__)), '../config.ini'),
  12. '/etc/voctomix/voctocore.ini',
  13. '/etc/voctomix.ini', # deprecated
  14. '/etc/voctocore.ini',
  15. os.path.expanduser('~/.voctomix.ini'), # deprecated
  16. os.path.expanduser('~/.voctocore.ini'),
  17. ]
  18. if Args.ini_file is not None:
  19. files.append(Args.ini_file)
  20. Config = SafeConfigParser()
  21. readfiles = Config.read(files)
  22. log = logging.getLogger('ConfigParser')
  23. log.debug('considered config-files: \n%s',
  24. "\n".join(["\t\t"+os.path.normpath(file) for file in files]) )
  25. log.debug('successfully parsed config-files: \n%s',
  26. "\n".join(["\t\t"+os.path.normpath(file) for file in readfiles]) )