PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/silversupport/develconfig.py

https://bitbucket.org/ianb/silverlining/
Python | 28 lines | 18 code | 4 blank | 6 comment | 3 complexity | f9d27c87a9a04f4b6688f2b0c3a33dfe MD5 | raw file
Possible License(s): GPL-2.0
  1. """Represents local/development services configuration"""
  2. import os
  3. from ConfigParser import ConfigParser
  4. __all__ = ['silverlining_conf', 'load_devel_config']
  5. silverlining_conf = os.path.join(
  6. os.environ['HOME'], '.silverlining.conf')
  7. def load_devel_config(app_name):
  8. """Load all the development configuration specific to this application
  9. This loads both ``[devel]`` and ``[devel:app_name]`` sections
  10. (with the latter taking precedence)
  11. """
  12. config = {}
  13. parser = ConfigParser()
  14. parser.read([silverlining_conf])
  15. sections = ['devel', 'devel:%s' % app_name]
  16. for section in sections:
  17. if not parser.has_section(section):
  18. continue
  19. for option in parser.options(section):
  20. value = parser.get(section, option)
  21. value = value.replace('APP_NAME', app_name)
  22. config[option] = value
  23. return config