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

« back to all changes in this revision

Viewing changes to ivle/config/__init__.py

Added config validation spec: ivle/config/ivle-spec.conf.
ivle.conf.conf: No longer needs to do the cast-to-int hack.
ivle.config: Runs against the validator (with a XXX problem).
setup.util: ivle-spec.conf is installed with a new whitelist.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import os
25
25
 
26
26
from configobj import ConfigObj
 
27
from validate import Validator
27
28
 
28
29
__all__ = ["ConfigError", "Config"]
29
30
 
55
56
    """
56
57
    The configuration object. Can be instantiated with no arguments (will
57
58
    implicitly find the ivle.conf file and load it).
 
59
 
 
60
    Automatically validates the file against the spec (found in
 
61
    ./ivle-spec.conf relative to this module).
58
62
    """
59
63
    def __init__(self, *args, **kwargs):
60
64
        conffile = search_conffile()
61
 
        super(Config, self).__init__(infile=conffile, *args, **kwargs)
 
65
        specfile = os.path.join(os.path.dirname(__file__), 'ivle-spec.conf')
 
66
        super(Config, self).__init__(infile=conffile, configspec=specfile,
 
67
                                     *args, **kwargs)
 
68
        # XXX This doesn't raise errors if it doesn't validate
 
69
        self.validate(Validator())