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

« back to all changes in this revision

Viewing changes to ivle/config/__init__.py

setup.configure: Fixed bug if usrmgt_magic is None. Does not write comment if
    this is the case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
        @param path: '/'-separated path to configuration option.
84
84
        @param value: Optional - value to write to the option.
85
85
        @param comment: Optional - comment string (lines separated by '\n's).
 
86
        Note: If only a comment is being inserted, and the value does not
 
87
        exist, fails silently.
86
88
        """
87
89
        path = path.split('/')
88
90
        # Iterate over each segment of the path, and find the section in conf
98
100
        if value is not _NO_VALUE:
99
101
            conf_section[keyname] = value
100
102
        if comment is not None:
101
 
            conf_section.comments[keyname] = comment.split('\n')
 
103
            try:
 
104
                conf_section[keyname]
 
105
            except KeyError:
 
106
                pass        # Fail silently
 
107
            else:
 
108
                conf_section.comments[keyname] = comment.split('\n')
102
109
 
103
110
    def get_by_path(self, path):
104
111
        """Gets an option's value, given a '/'-separated path.