<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set(self, key, value, filepath):
 """Set configuration parameter. Writes 'value' on 'key' to the configuration file given in 'filepath'. Configuration parameter in 'key' must follow the schema <section>.<option> . :param key: key to set :param value: value to set :param filepath: configuration file """

        if not filepath:
            raise RuntimeError("Configuration file not given")

        if not self.__check_config_key(key):
            raise RuntimeError("%s parameter does not exists or cannot be set" % key)

        config = configparser.SafeConfigParser()

        if os.path.isfile(filepath):
            config.read(filepath)

        section, option = key.split('.')

        if section not in config.sections():
            config.add_section(section)

        try:
            config.set(section, option, value)
        except TypeError as e:
            raise RuntimeError(str(e))

        try:
            with open(filepath, 'w') as f:
                config.write(f)
        except IOError as e:
            raise RuntimeError(str(e))

        return CMD_SUCCESS