本文整理汇总了Python中weechat.config_new_option函数的典型用法代码示例。如果您正苦于以下问题:Python config_new_option函数的具体用法?Python config_new_option怎么用?Python config_new_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了config_new_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_own_config_file
def init_own_config_file():
# set up configuration options and load config file
global CONFIG_FILE, CONFIG_SECTIONS
CONFIG_FILE = weechat.config_new(SCRIPT_NAME, '', '')
CONFIG_SECTIONS = {}
CONFIG_SECTIONS['section_name'] = weechat.config_new_section(
CONFIG_FILE, 'section_name', 0, 0, '', '', '', '', '', '', '', '', '', '')
for option, typ, desc, default in [
('option_name',
'boolean',
'option description',
'off'),
('option_name2',
'boolean',
'option name2 description ',
'on'),
('option_name3',
'string',
'option name3 description',
''),
('option_name4',
'string',
'option name4 description',
'set an default string here'),
]:
weechat.config_new_option(
CONFIG_FILE, CONFIG_SECTIONS['section_name'], option, typ, desc, '', 0,
0, default, default, 0, '', '', '', '', '', '')
weechat.config_read(CONFIG_FILE)
示例2: __init__
def __init__(self, filename):
''' Initialize the configuration. '''
self.filename = filename
self.config_file = weechat.config_new(self.filename, '', '')
self.sorting_section = None
self.case_sensitive = False
self.group_irc = True
self.rules = []
self.highest = 0
self.__case_sensitive = None
self.__group_irc = None
self.__rules = None
if not self.config_file:
log('Failed to initialize configuration file "{}".'.format(self.filename))
return
self.sorting_section = weechat.config_new_section(self.config_file, 'sorting', False, False, '', '', '', '', '', '', '', '', '', '')
if not self.sorting_section:
log('Failed to initialize section "sorting" of configuration file.')
weechat.config_free(self.config_file)
return
self.__case_sensitive = weechat.config_new_option(
self.config_file, self.sorting_section,
'case_sensitive', 'boolean',
'If this option is on, sorting is case sensitive.',
'', 0, 0, 'off', 'off', 0,
'', '', '', '', '', ''
)
self.__group_irc = weechat.config_new_option(
self.config_file, self.sorting_section,
'group_irc', 'boolean',
'If this option is on, the script pretends that IRC channel/private buffers are renamed to "irc.server.{network}.{channel}" rather than "irc.{network}.{channel}".' +
'This ensures that thsee buffers are grouped with their respective server buffer.',
'', 0, 0, 'on', 'on', 0,
'', '', '', '', '', ''
)
self.__rules = weechat.config_new_option(
self.config_file, self.sorting_section,
'rules', 'string',
'An ordered list of sorting rules encoded as JSON. See /help autosort for commands to manipulate these rules.',
'', 0, 0, Config.default_rules, Config.default_rules, 0,
'', '', '', '', '', ''
)
if weechat.config_read(self.config_file) != weechat.WEECHAT_RC_OK:
log('Failed to load configuration file.')
if weechat.config_write(self.config_file) != weechat.WEECHAT_RC_OK:
log('Failed to write configuration file.')
self.reload()
示例3: policy_create_option_cb
def policy_create_option_cb(data, config_file, section, name, value):
"""Callback for creating a new policy option when the user sets one
that doesn't exist."""
weechat.config_new_option(
config_file, section, name, 'boolean', '', '', 0, 0, value, value, 0,
'', '', '', '', '', '')
return weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED
示例4: fish_config_init
def fish_config_init():
global fish_config_file, fish_config_section, fish_config_option
fish_config_file = weechat.config_new(CONFIG_FILE_NAME,
"fish_config_reload_cb", "")
if not fish_config_file:
return
# look
fish_config_section["look"] = weechat.config_new_section(fish_config_file,
"look", 0, 0, "", "", "", "", "", "", "", "", "", "")
if not fish_config_section["look"]:
weechat.config_free(fish_config_file)
return
fish_config_option["announce"] = weechat.config_new_option(
fish_config_file, fish_config_section["look"], "announce",
"boolean", "annouce if messages are being encrypted or not", "", 0,
0, "on", "on", 0, "", "", "", "", "", "")
fish_config_option["marker"] = weechat.config_new_option(
fish_config_file, fish_config_section["look"], "marker",
"string", "marker for important FiSH messages", "", 0, 0,
"O<", "O<", 0, "", "", "", "", "", "")
fish_config_option["mark_position"] = weechat.config_new_option(
fish_config_file, fish_config_section["look"], "mark_position",
"integer", "put marker for encrypted INCOMING messages at start or end", "off|begin|end",
0,2, "off", "off", 0, "", "", "", "", "", "")
fish_config_option["mark_encrypted"] = weechat.config_new_option(
fish_config_file, fish_config_section["look"], "mark_encrypted",
"string", "marker for encrypted INCOMING messages", "", 0, 0,
"*", "*", 0, "", "", "", "", "", "")
# color
fish_config_section["color"] = weechat.config_new_section(fish_config_file,
"color", 0, 0, "", "", "", "", "", "", "", "", "", "")
if not fish_config_section["color"]:
weechat.config_free(fish_config_file)
return
fish_config_option["alert"] = weechat.config_new_option(
fish_config_file, fish_config_section["color"], "alert",
"color", "color for important FiSH message markers", "", 0, 0,
"lightblue", "lightblue", 0, "", "", "", "", "", "")
# keys
fish_config_section["keys"] = weechat.config_new_section(fish_config_file,
"keys", 0, 0,
"fish_config_keys_read_cb", "",
"fish_config_keys_write_cb", "", "",
"", "", "", "", "")
if not fish_config_section["keys"]:
weechat.config_free(fish_config_file)
return
示例5: theme_config_init
def theme_config_init():
"""Initialization of configuration file. Sections: ???."""
global theme_config_file, theme_config_option
theme_config_file = weechat.config_new(THEME_CONFIG_FILE_NAME,
'theme_config_reload_cb', '')
if not theme_config_file:
return
# section "color"
section_color = weechat.config_new_section(
theme_config_file, 'color', 0, 0, '', '', '', '', '', '', '', '', '', '')
if not section_color:
weechat.config_free(theme_config_file)
return
theme_config_option['color_script'] = weechat.config_new_option(
theme_config_file, section_color,
'script', 'color', 'Color for script names', '', 0, 0,
'cyan', 'cyan', 0, '', '', '', '', '', '')
theme_config_option['color_installed'] = weechat.config_new_option(
theme_config_file, section_color,
'installed', 'color', 'Color for "installed" indicator', '', 0, 0,
'yellow', 'yellow', 0, '', '', '', '', '', '')
theme_config_option['color_running'] = weechat.config_new_option(
theme_config_file, section_color,
'running', 'color', 'Color for "running" indicator', '', 0, 0,
'lightgreen', 'lightgreen', 0, '', '', '', '', '', '')
theme_config_option['color_obsolete'] = weechat.config_new_option(
theme_config_file, section_color,
'obsolete', 'color', 'Color for "obsolete" indicator', '', 0, 0,
'lightmagenta', 'lightmagenta', 0, '', '', '', '', '', '')
theme_config_option['color_unknown'] = weechat.config_new_option(
theme_config_file, section_color,
'unknown', 'color', 'Color for "unknown status" indicator', '', 0, 0,
'lightred', 'lightred', 0, '', '', '', '', '', '')
theme_config_option['color_language'] = weechat.config_new_option(
theme_config_file, section_color,
'language', 'color', 'Color for language names', '', 0, 0,
'lightblue', 'lightblue', 0, '', '', '', '', '', '')
# section "themes"
section_themes = weechat.config_new_section(
theme_config_file, 'themes', 0, 0, '', '', '', '', '', '', '', '', '', '')
if not section_themes:
weechat.config_free(theme_config_file)
return
theme_config_option['themes_url'] = weechat.config_new_option(
theme_config_file, section_themes,
'url', 'string', 'URL for file with list of themes', '', 0, 0,
'http://www.weechat.org/files/themes.json.gz',
'http://www.weechat.org/files/themes.json.gz', 0, '', '', '', '', '', '')
theme_config_option['themes_cache_expire'] = weechat.config_new_option(
theme_config_file, section_themes,
'cache_expire', 'integer', 'Local cache expiration time, in minutes '
'(-1 = never expires, 0 = always expires)', '',
-1, 60*24*365, '60', '60', 0, '', '', '', '', '', '')
theme_config_option['themes_dir'] = weechat.config_new_option(
theme_config_file, section_themes,
'dir', 'string', 'Local directory for themes', '', 0, 0,
'%h/themes', '%h/themes', 0, '', '', '', '', '', '')
示例6: initialize_config
def initialize_config(name):
global config
config = {}
global config_file
config_file = weechat.config_new(name, 'my_config_reload_cb', '')
global config_values
config_values = {}
global config_keys
config_keys = {
'strings' : ['url', 'streams', 'stream_options', 'format']
#'integers' : ['time_delay']
}
# Available colors
global colors
colors = ['white' , 'black', 'blue', 'green', 'lighred', 'red',
'magenta', 'brown', 'yellow', 'lightgreen', 'cyan',
'lightcyan', 'lightblue', 'lightmagenta', 'darkgray', 'gray']
if not config_file:
return
section = weechat.config_new_section(config_file, 'config', 0,0, '', '', '', '', '', '', '', '', '', '')
config['url'] = weechat.config_new_option(config_file, section,
'icecast_json_url', 'string', 'http directory for /status-json.xsl',
'', 0, 0,
'http://icecast.nashgul.com.es/status-json.xsl', 'http://icecast.nashgul.com.es/status-json.xsl', 1,
'', '',
'load_str_vars_cb', '',
'', '')
config['streams'] = weechat.config_new_option(config_file, section,
'streams', 'string', 'mounts to show (without slash and separated by commas)',
'', 0, 0,
'nashgul', 'nashgul', 1,
'check_mounts_cb', '',
'load_str_vars_cb', '',
'', '')
config['stream_options'] = weechat.config_new_option(config_file, section,
'stream_options', 'string', 'stream options to show',
'', 0, 0,
'url,artist,title,listeners', 'url,artist,title,listeners', 1,
'', '',
'load_str_vars_cb', '',
'', '')
config['format'] = weechat.config_new_option(config_file, section,
'output_format', 'string', 'Output string format (%s: attribute, %\'color\'; i.e.: Now playing on %red%s: %blue%s - %s - %s)',
'', 0, 0,
'%redAhora suena en %cyan%s%yellow: %lightblue%s %yellow- %lightblue%s %yellow( %magentaOyentes%yellow: %lightblue%s %yellow)', '%lightredAhora suena en %cyan%s%yellow: %lightblue%s %yellow- %lightblue%s %yellow( %magentaOyentes%yellow: %lightblue%s %yellow)', 1,
'', '',
'load_str_vars_cb', '',
'', '')
示例7: bas_config_init
def bas_config_init():
"""
Initialization of configuration file.
Sections: buffer.
"""
global bas_config_file, bas_options
bas_config_file = weechat.config_new(CONFIG_FILE_NAME,
"bas_config_reload_cb", "")
if bas_config_file == "":
return
# section "look"
section_look = weechat.config_new_section(
bas_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "")
if not section_look:
weechat.config_free(bas_config_file)
return
# options in section "look"
bas_options["look_timer"] = weechat.config_new_option(
bas_config_file, section_look, "timer", "integer",
"Timer used to delay the set of properties (in milliseconds, "
"0 = don't use a timer)",
"", 0, 2147483647, "1", "1", 0, "", "", "", "", "", "")
# section "buffer"
section_buffer = weechat.config_new_section(
bas_config_file, "buffer", 1, 1, "", "", "", "", "", "",
"bas_config_buffer_create_option_cb", "", "", "")
if not section_buffer:
weechat.config_free(bas_config_file)
return
示例8: keys_create_option_cb
def keys_create_option_cb(data, config_file, section, option, value):
if not keys_check_option_cb('', option, value):
weechat.prnt('',
"WeeSodium keys must be stored using WeeChat's secured "
"data storage. See /help secure for info on this.")
return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
option_split = option.split('.')
if len(option_split) != 2:
weechat.prnt('',
"Both a server and a channel are required to be entered "
"as the key for the config option. For example: "
"/set weesodium.keys.example.#weesodium "
"${sec.data.wskey}")
return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
weeopt = weechat.config_new_option(config_file, section, option, 'string',
'key', '', 0, 0, '', value, 0,
'keys_check_option_cb', '', '', '',
'', '')
if not weeopt:
return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
option_split = option.split('.')
if len(option_split) == 2 and value.startswith('${sec.data.'):
channel_key = weechat.string_eval_expression(value, {}, {}, {})
channel_data[option] = WeeSodiumChannel(channel_key)
return weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED
示例9: theme_config_init
def theme_config_init():
"""Initialization of configuration file. Sections: color, themes."""
global theme_cfg_file, theme_cfg
theme_cfg_file = weechat.config_new(THEME_CONFIG_FILENAME,
'theme_config_reload_cb', '')
# section "color"
section = weechat.config_new_section(
theme_cfg_file, 'color', 0, 0,
'', '', '', '', '', '', '', '', '', '')
theme_cfg['color_script'] = weechat.config_new_option(
theme_cfg_file, section, 'script', 'color',
'Color for script names', '', 0, 0,
'cyan', 'cyan', 0, '', '', '', '', '', '')
theme_cfg['color_installed'] = weechat.config_new_option(
theme_cfg_file, section, 'installed', 'color',
'Color for "installed" indicator', '', 0, 0,
'yellow', 'yellow', 0, '', '', '', '', '', '')
theme_cfg['color_running'] = weechat.config_new_option(
theme_cfg_file, section, 'running', 'color',
'Color for "running" indicator', '', 0, 0,
'lightgreen', 'lightgreen', 0, '', '', '', '', '', '')
theme_cfg['color_obsolete'] = weechat.config_new_option(
theme_cfg_file, section, 'obsolete', 'color',
'Color for "obsolete" indicator', '', 0, 0,
'lightmagenta', 'lightmagenta', 0, '', '', '', '', '', '')
theme_cfg['color_unknown'] = weechat.config_new_option(
theme_cfg_file, section, 'unknown', 'color',
'Color for "unknown status" indicator', '', 0, 0,
'lightred', 'lightred', 0, '', '', '', '', '', '')
theme_cfg['color_language'] = weechat.config_new_option(
theme_cfg_file, section, 'language', 'color',
'Color for language names', '', 0, 0,
'lightblue', 'lightblue', 0, '', '', '', '', '', '')
# section "themes"
section = weechat.config_new_section(
theme_cfg_file, 'themes', 0, 0,
'', '', '', '', '', '', '', '', '', '')
theme_cfg['themes_url'] = weechat.config_new_option(
theme_cfg_file, section,
'url', 'string', 'URL for file with themes (.tar.bz2 file)', '', 0, 0,
THEME_URL, THEME_URL, 0, '', '', '', '', '', '')
theme_cfg['themes_cache_expire'] = weechat.config_new_option(
theme_cfg_file, section,
'cache_expire', 'integer', 'Local cache expiration time, in minutes '
'(-1 = never expires, 0 = always expires)', '',
-1, 60 * 24 * 365, '60', '60', 0, '', '', '', '', '', '')
theme_cfg['themes_dir'] = weechat.config_new_option(
theme_cfg_file, section,
'dir', 'string', 'Local directory for themes', '', 0, 0,
'%h/themes', '%h/themes', 0, '', '', '', '', '', '')
示例10: __init__
def __init__(self) :
global weeNS_server_opt, weeNS_config_file, weeNS_config_server_section
self.buffer = None
self.hook_fd = None
self.socket = None
self.netbuffer = ''
self.chats = []
self.contacts = {}
self.options = {
'host' : weechat.config_new_option(weeNS_config_file, weeNS_config_server_section,
'host', 'string', 'Server Host (default: ns-server.epita.fr)', '', 0, 0,
'ns-server.epita.fr', 'ns-server.epita.fr', 0, '', '', '', '', '', ''),
'port' : weechat.config_new_option(weeNS_config_file, weeNS_config_server_section,
'port', 'string', 'Server Port (default: 4242)', '', 0, 0,
'4242', '4242', 0, '', '', '', '', '', ''),
'login' : weechat.config_new_option(weeNS_config_file, weeNS_config_server_section,
'login', 'string', 'User login (ie: login_x)', '', 0, 0,
'login_x', 'login_x', 0, '', '', '', '', '', ''),
'password' : weechat.config_new_option(weeNS_config_file, weeNS_config_server_section,
'password', 'string', 'User password (ie: your SOCKS password)', '', 0, 0,
'xxxxxx', 'xxxxxx', 0, '', '', '', '', '', ''),
'location' : weechat.config_new_option(weeNS_config_file, weeNS_config_server_section,
'location', 'string', 'User location (ie: at home)', '', 0, 0,
'-', '-', 0, '', '', '', '', '', ''),
'data' : weechat.config_new_option(weeNS_config_file, weeNS_config_server_section,
'data', 'string', 'User data (ie: j\'aime les chips)', '', 0, 0,
'-', '-', 0, '', '', '', '', '', ''),
'contacts' : weechat.config_new_option(weeNS_config_file, weeNS_config_server_section,
'contacts', 'string', 'Comma separated login list (ie: sb,rn)', '', 0, 0,
'', '', 0, '', '', '', '', '', '')}
示例11: setup_config_file
def setup_config_file(self):
"""Initialize the configuration."""
config_file = weechat.config_new(
self._config_name,
self._reload_cb,
self._reload_cb_data)
if not config_file:
return None
for section in SCRIPT_CONFIG:
config_section = weechat.config_new_section(
config_file,
section,
0, 0, "", "", "", "", "", "", "", "", "", ""
)
if not config_section:
weechat.config_free(config_file)
return None
for option_name, props in SCRIPT_CONFIG[section].items():
weechat.config_new_option(
config_file,
config_section,
option_name,
props['type'],
props['desc'],
props['string_values'],
props['min'],
props['max'],
props['default'],
props['default'],
0,
props['check_cb'],
"",
props['change_cb'],
props['change_data'],
props['delete_cb'],
""
)
return config_file
示例12: bas_config_buffer_create_option_cb
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
示例13: fish_config_keys_read_cb
def fish_config_keys_read_cb(data, config_file, section_name, option_name,
value):
global fish_keys
option = weechat.config_new_option(config_file, section_name, option_name,
"string", "key", "", 0, 0, "", value, 0, "", "", "", "", "", "")
if not option:
return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
fish_keys[option_name] = value
return weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED
示例14: jmh_config_init
def jmh_config_init():
""" Initialize config file: create sections and options in memory. """
global jmh_config_file, jmh_config_section
jmh_config_file = weechat.config_new("jabber_message_handler",
"jmh_config_reload_cb", "")
if not jmh_config_file:
return
# options
jmh_config_section["options"] = weechat.config_new_section(
jmh_config_file, "options", 0, 0, "", "", "", "", "",
"", "", "", "", "")
if not jmh_config_section["options"]:
weechat.config_free(jmh_config_file)
return
# prototype option = weechat.config_new_option(
# config_file, section,
# name, type, description,
# string_values, min, max, default_value, value, null_value_allowed,
# callback_check_value, callback_check_value_data,
# callback_change, callback_change_data,
# callback_delete, callback_delete_data)
jmh_config_option["enabled"] = weechat.config_new_option(
jmh_config_file, jmh_config_section["options"],
"enabled", "boolean", "jabber_message_handler service enabled",
"", 0, 0, "off", "off", 0,
"", "", "", "", "", "")
jmh_config_option["log"] = weechat.config_new_option(
jmh_config_file, jmh_config_section["options"],
"log", "string", "jabber_message_handler events log file",
"", 0, 0, "~/.weechat/logs/events", "~/.weechat/logs/events", 0,
"", "", "", "", "", "")
jmh_config_option["verbose"] = weechat.config_new_option(
jmh_config_file, jmh_config_section["options"],
"verbose", "boolean", "set verbose on/off",
"", 0, 0, "off", "off", 0,
"", "", "", "", "", "")
示例15: keys_read_option_cb
def keys_read_option_cb(data, config_file, section, option, value):
"""Read option callback: load keys from config options"""
weeopt = weechat.config_new_option(config_file, section, option, 'string',
'key', '', 0, 0, '', value, 0,
'keys_check_option_cb', '', '', '',
'', '')
if not weeopt:
return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
option_split = option.split('.')
if len(option_split) == 2 and value.startswith('${sec.data.'):
channel_key = weechat.string_eval_expression(value, {}, {}, {})
channel_data[option] = WeeSodiumChannel(channel_key)
return weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED