#!/usr/bin/python2

# Set python's config files from the shell.
# Usage: set-conf-item filename.conf section item value

# WARNING: comments and item order within config file will be destoryed

import sys
try:
    from vdsm.config import config
except:
    from six.moves import configparser
    config = configparser.ConfigParser()

(_, fname, section, item, value) = sys.argv
config.read(fname)
if not config.has_section(section):
    config.add_section(section)
config.set(section, item, value)
config.write(file(fname, 'w'))
