Beispiel #1
0
def open_confset_config(confset):
    '''
    Open environment configuration.
    '''
    cp = PathConfigParser(dict_type=OrderedDict)
    paths = ['conf/%s/%s.cfg' % (confset, confset)]
    print 'Loading configuration for writing...'
    cp.read(paths)
    return cp
Beispiel #2
0
def open_confset_usr_config(confset):
    '''
    Open current user's environment configuration.
    '''
    cp = PathConfigParser(dict_type=OrderedDict)
    paths = ['conf/%s/%s.usr.cfg' % (confset, os.getlogin())]
    print 'Loading user configuration for writing...'
    cp.read(paths)
    return cp
Beispiel #3
0
def load_confset_config(confset):
    '''
    Loads environment configuration.
    
    The following path will be searched:
    conf/default/default.cfg
    conf/%(env)/%(env).cfg
    conf/%(env)/%(user_name).usr.cfg    
    
    While %(confset) is the environment name, %(user_name) is current login user.
    '''
    cp = PathConfigParser(dict_type=OrderedDict)
    paths = [
             'conf/default/default.cfg',
             'conf/%s/%s.cfg' % (confset, confset),
             'conf/%s/%s.usr.cfg' % (confset, os.environ.get("USER"))
             ]
    print 'Loading configuration...'
    for path in paths:
        print path
    cp.read(paths)
    cp.defaults()['__confset__'] = confset
    return cp