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

« back to all changes in this revision

Viewing changes to ivle/config/__init__.py

setup.configure: Replaced use of legacy conf.py for loading existing values.
    Now goes directly through the new ivle.config module.
    Removed CONFIG_OPTIONS dict mapping new names to legacy names.
ivle.config: Added Config.get_by_path to facilitate this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
                                     *args, **kwargs)
68
68
        # XXX This doesn't raise errors if it doesn't validate
69
69
        self.validate(Validator())
 
70
 
 
71
    def get_by_path(self, path):
 
72
        """Gets an option's value, given a '/'-separated path.
 
73
        @param path: '/'-separated path to configuration option.
 
74
        @raise KeyError: if no config option is at that path.
 
75
        """
 
76
        # Iterate over each segment of the path, and find the value in conf file
 
77
        value = self
 
78
        for seg in path.split('/'):
 
79
            value = value[seg]      # May raise KeyError
 
80
        return value