PageRenderTime 71ms CodeModel.GetById 50ms app.highlight 3ms RepoModel.GetById 17ms app.codeStats 0ms

/silversupport/develconfig.py

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