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
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