~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/conf/conf.py

Added module ivle.config, which takes care of some work interfacing with
    configobj, including searching for the file and opening the object.
ivle.conf.conf now uses this instead of having its own search.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
import configobj
31
31
 
32
 
def search_conffile():
33
 
    """
34
 
    Search for the config file, and return it as a filename.
35
 
    1. Environment var IVLECONF (full filename).
36
 
    2. ./etc/ivle.conf
37
 
    3. /etc/ivle/ivle.conf
38
 
    """
39
 
    if 'IVLECONF' in os.environ:
40
 
        fname = os.environ['IVLECONF']
41
 
        if os.path.exists(fname):
42
 
            return fname
43
 
    if os.path.exists('./etc/ivle.conf'):
44
 
        return './etc/ivle.conf'
45
 
    if os.path.exists('/etc/ivle/ivle.conf'):
46
 
        return '/etc/ivle/ivle.conf'
47
 
    raise RuntimeError("Could not find IVLE config file")
 
32
import ivle.config
48
33
 
49
34
try:
50
 
    conffile = search_conffile()
51
 
except RuntimeError, e:
 
35
    conf = ivle.config.Config()
 
36
except ivle.config.ConfigError, e:
52
37
    raise ImportError(str(e))
53
38
 
54
 
conf = configobj.ConfigObj(conffile)
55
 
 
56
39
# This dict maps legacy config option names to new config option paths
57
40
# ('section/option_name')
58
41
CONFIG_OPTIONS = {