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

« back to all changes in this revision

Viewing changes to setup/configure.py

ivle.config.Config: Added set_by_path method (based on code from
    setup.configure).
setup.configure: Use ivle.config.Config.set_by_path rather than doing it
    manually.

Show diffs side-by-side

added added

removed removed

Lines of Context:
341
341
    conf_options['plugins/forum/secret'] = forum_secret
342
342
 
343
343
    for opt in config_options:
344
 
        newopt_path = opt.option_name.split('/')
345
 
        # Iterate over each segment of the path, and find the section in conf
346
 
        # file to insert the value into (use all but the last path segment)
347
 
        conf_section = conf
348
 
        for seg in newopt_path[:-1]:
349
 
            # Create the section if it isn't there
350
 
            if seg not in conf_section:
351
 
                conf_section[seg] = {}
352
 
            conf_section = conf_section[seg]
353
 
        # The final path segment names the key to insert into
354
 
        keyname = newopt_path[-1]
355
344
        value = conf_options[opt.option_name]
356
345
        if value is not None:
357
 
            conf_section[keyname] = value
358
 
            conf_section.comments[keyname] = opt.comment.split('\n')
 
346
            conf.set_by_path(opt.option_name, value, opt.comment)
359
347
 
360
348
    conf.write()
361
349