summaryrefslogtreecommitdiff
path: root/voctocore/lib/config.py
blob: 4567acfaad00139ace293d98c4a2d5acfcf8e8ca (plain)
  1. import os.path
  2. from configparser import SafeConfigParser
  3. from lib.args import Args
  4. __all__ = ['Config']
  5. def getlist(self, section, option):
  6. return [x.strip() for x in self.get(section, option).split(',')]
  7. SafeConfigParser.getlist = getlist
  8. files = [
  9. os.path.join(os.path.dirname(os.path.realpath(__file__)), '../default-config.ini'),
  10. os.path.join(os.path.dirname(os.path.realpath(__file__)), '../config.ini'),
  11. '/etc/voctomix.ini', # deprecated
  12. '/etc/voctocore.ini',
  13. os.path.expanduser('~/.voctomix.ini'), # deprecated
  14. os.path.expanduser('~/.voctocore.ini'),
  15. ]
  16. if Args.ini_file is not None:
  17. files.append(Args.ini_file)
  18. Config = SafeConfigParser()
  19. Config.read(files)