Example #1
0
def bas_config_buffer_create_option_cb(data, config_file, section, option_name, value):
    option = weechat.config_search_option(config_file, section, option_name)
    if option:
        return weechat.config_option_set(option, value, 1)
    else:
        option = weechat.config_new_option(
            config_file, section, option_name, "string", "", "", 0, 0, "", value, 0, "", "", "", "", "", ""
        )
        if not option:
            return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
        return weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
Example #2
0
def bas_config_buffer_create_option_cb(data, config_file, section, option_name, value):
    option = weechat.config_search_option(config_file, section, option_name)
    if option:
        return weechat.config_option_set (option, value, 1)
    else:
        option = weechat.config_new_option (config_file, section, option_name, "string",
                                            "", "", 0, 0, "", value, 0,
                                            "", "", "", "", "", "")
        if not option:
            return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
        return weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
Example #3
0
    def set_value(self, section_name, option_name, value):
        """Set a configuration option."""
        section = weechat.config_search_section(
            self._config_file,
            section_name)
        option = weechat.config_search_option(
            self._config_file,
            section,
            option_name)

        ret = weechat.config_option_set(option, value, 1)
        return ret
Example #4
0
    def get_value(self, section_name, option_name):
        """Return a value from the configuration."""
        # This is a lot of work to just get the value of an option.
        section = weechat.config_search_section(
            self._config_file, section_name
        )
        option = weechat.config_search_option(
            self._config_file, section, option_name
        )

        # Automatically choose the correct weechat.config_*
        # function and call it.
        config_function = "config_{type}".format(
            type=SCRIPT_CONFIG[section_name][option_name]['type'])
        value = getattr(weechat, config_function)(option)
        return value